preferring  or () in list of error codes?
ben+python at benfinney.id.au
Thu Jun 11 19:56:14 EDT 2009
Gunter Henriksen <gunterhenriksen at gmail.com> writes:
> > Try, then, this tuple:
> > event_timestamp = (2009, 06, 04, 05, 02, 03)
> > (year, month, day, hour, minute, second) = event_timestamp
> I totally agree about anything to do with immutability, I think the
> relative ordering of the elements in this example may be orthogonal to
> the concept of a tuple as an object whose elements have a semantic
> meaning implicitly defined by location in the sequence... in other
> words knowing that element i+1 is in some sense ordinally smaller than
> element i does not give me much information about what element i+1
> actually is.
The point of each position having a different semantic meaning is that
tuple unpacking works as above. You need to know the meaning of each
position in order to unpack it to separate names, as above.
So two tuples that differ only in the sequence of their items are
different in meaning. This is unlike a list, where the sequence of items
does *not* affect the semantic meaning of each item.
Note that I'm well aware that the language doesn't impose this as a hard
restriction; but that says more about Python's “consenting adults”
philosophy than anything else.
\ “I went to a general store. They wouldn't let me buy anything |
`\ specifically.” —Steven Wright |
More information about the Python-list