Named tuples
Carlos Ribeiro
carribeiro at gmail.com
Wed Nov 17 20:23:02 EST 2004
On Wed, 17 Nov 2004 17:13:45 -0800, Jeff Shannon <jeff at ccvcorp.com> wrote:
> Carlos Ribeiro wrote:
>
> >4. Named attribute access is supported by __getattr__. Names are
> >looked up on the magic __names__ attribute of the tuple.
> >
> >5. On slicing, a named tuple should return another named tuple. This
> >means that the __names__ tuple has to be sliced also.
> >
> >
>
> Hm. If __names__ is a tuple, then does that tuple have a __names__
> attribute as well?
>
> (In practice, I can't imagine any reason why tuple.__names__.__names__
> should ever be anything other than None, but the potential recursiveness
> makes me nervous...)
Humm. The worst case is if it's done in a circular fashion, as in:
mytuple.__names__ = nametuple
nametuple.__names__ = mytuple
That's weird. The best that I can imagine now is that it would be
illegal to assign a named tuple to the __names__ member of another
tuple.
--
Carlos Ribeiro
Consultoria em Projetos
blog: http://rascunhosrotos.blogspot.com
blog: http://pythonnotes.blogspot.com
mail: carribeiro at gmail.com
mail: carribeiro at yahoo.com
More information about the Python-list
mailing list