Read all sections on tuples.
We have already read all sections on lists.
Read.
Read.
skip; we will have our own exercises and assignments.
Keys in a dictionary and items in a set must be hashable.
Hashable is a little more restrictive than just immutable.
To be hashable the object must meet these two requirements:
1) the object must be immutable
2) the object can not contain a reference to an object that is not hashable.
Some examples:
int float str are immutable and contain no references, so they are hashable.
list set dictionary are mutable because they can add a new item, so they are not hashable.
tuple is sometimes hashable, but if it contains a referece to an object that is not hashable,
it is not hashable.
Examples of tuples:
1) A tuple containing three items that refer to an int, a float, and a str, is hashable.
2) A tuple containing a reference to a list is not hashable.
3) tuple1 contains a reference to tuple2, and tuple2 contains a reference to tuple3
et cetera, all the way down to tuple27.
If tuple27 contains a reference to a list it is not hashable.
Thus tuple26 is not hashable, and then tuple25 is not hashable, all the way
back to tuple1 are all not hashable.
Scan. The example of two-character strings is a little suprising. A str object object is usually processed as a whole object unless square brackets are used to specify part of the str object.
del is an operator, not a function or a method.
omit
Read only this section.
Using named tuples gives you some benefits that may not be immediately obvious.
They're well suited to working with well defined records from a file or database.