Named tuples

Carlos Ribeiro carribeiro at
Thu Nov 18 02:23:02 CET 2004

On Wed, 17 Nov 2004 17:13:45 -0800, Jeff Shannon <jeff at> 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

Carlos Ribeiro
Consultoria em Projetos
mail: carribeiro at
mail: carribeiro at

More information about the Python-list mailing list