General question about Python design goals

Fredrik Lundh fredrik at pythonware.com
Thu Dec 1 11:20:50 EST 2005


Alex Martelli wrote:

> 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).

iirc, providing a python-level API to the SequenceStruct stuff
has been proposed before, and rejected.

(fwiw, I'm not sure the time and stat tuples would have been
tuples if the standard library had been designed today; the C-
level stat struct doesn't have a fixed number of members, and
the C-level time API would have been better off as a light-
weight "time" type (similar to sockets, stdio-based files, and
other C-wrapper types))

</F>






More information about the Python-list mailing list