9.5. Nested Dict of Many
Similar to JSON's list of objects
Examples:
>>> DATA = {
... 'username': 'alice',
... 'password': 'secret',
... 'age': 30,
... 'lastlogin': '2000-01-01',
... 'is_active': True,
... 'is_staff': True,
... 'is_superuser': False,
... 'emails': ('alice@example.com', 'alice@example.edu'),
... 'permissions': ['auth.add_user', 'auth.change_user'],
... 'groups': {'users', 'staff', 'admins'},
... 'friends': [
... {'username': 'bob', 'email': 'bob@example.com'},
... {'username': 'carol', 'email': 'carol@example.com'},
... {'username': 'dave', 'email': 'dave@example.org'},
... {'username': 'eve', 'email': 'eve@example.org'},
... {'username': 'mallory', 'email': 'mallory@example.net'},
... ],
... }
9.5.1. Format
Content could be even more complex data structure with nested items
>>> DATA = {
... 'username': 'alice',
... 'password': 'secret',
... 'age': 30,
... 'lastlogin': '2000-01-01',
... 'is_active': True,
... 'is_staff': True,
... 'is_superuser': False,
... 'emails': ('alice@example.com', 'alice@example.edu'),
... 'permissions': ['auth.add_user', 'auth.change_user'],
... 'groups': {'users', 'staff', 'admins'},
... 'friends': [
... {'username': 'bob', 'email': 'bob@example.com'},
... {'username': 'carol', 'email': 'carol@example.com'},
... {'username': 'dave', 'email': 'dave@example.org'},
... {'username': 'eve', 'email': 'eve@example.org'},
... {'username': 'mallory', 'email': 'mallory@example.net'},
... ],
... }
9.5.2. Length
>>> DATA = {
... 'username': 'alice',
... 'password': 'secret',
... 'age': 30,
... 'lastlogin': '2000-01-01',
... 'is_active': True,
... 'is_staff': True,
... 'is_superuser': False,
... 'emails': ('alice@example.com', 'alice@example.edu'),
... 'permissions': ['auth.add_user', 'auth.change_user'],
... 'groups': {'users', 'staff', 'admins'},
... 'friends': [
... {'username': 'bob', 'email': 'bob@example.com'},
... {'username': 'carol', 'email': 'carol@example.com'},
... {'username': 'dave', 'email': 'dave@example.org'},
... {'username': 'eve', 'email': 'eve@example.org'},
... {'username': 'mallory', 'email': 'mallory@example.net'},
... ],
... }
>>> len(DATA)
11
>>> len(DATA['friends'])
5
>>> len(DATA['friends'][0]['username'])
3