Collections
Lists and dictionaries are ordinary Python containers. The interpreter adds the Lupe rules around indexing and equality, and it does not copy a container when a name is assigned.
alias
and
numbers
are the same list. Assigning a collection to another variable stores another reference. Nested lists and dictionaries are the same kind of value, so a list may contain a dictionary and a dictionary may contain a list.
Lists
Indexes start at zero. The index must be an integer. A negative index is an index error in this draft, as is an index past the last element. Assignment to an existing index replaces that element. There is no slice syntax.
Dictionaries
Keys are strings. A missing key on a read is a key error. Assignment replaces a value or adds a key, and new keys are stored at the end. Iteration and
keys()
follow that insertion order.
Equality walks the containers by value. Two lists are equal when they have the same length and equal elements in the same places. Two dictionaries are equal when they have the same keys and equal values. Numbers compare numerically, so
1
equals
1.0
. A boolean is not a number, so
true
does not equal
1
.