General question about Python design goals

Alex Martelli aleax at mail.comcast.net
Thu Dec 1 10:46:38 EST 2005


Steve Holden <steve at holdenweb.com> wrote:
   ...
> Presumably because it's necessary to extract the individual values 
> (though os.stat results recently became addressable by attribute name as
> well as by index, and this is an indication of the originally intended
> purpose of tuples).

Yep -- "time tuples" have also become pseudo-tuples (each element can be
accessed by name as well as by index) a while ago, and I believe there's
one more example besides stats and times (but I can't recall which one).

Perhaps, if the tuple type _in general_ allowed naming the items in a
smooth way, that might help users see a tuple as "a kind of
``struct''... which also happens to be immutable".  There are a few such
"supertuples" (with item-naming) in the cookbook, but I wonder if it
might not be worth having such functionality in the standard library
(for this clarification as well as, sometimes, helping the readability
of some user code).


Alex



More information about the Python-list mailing list