Factory for Struct-like classes

eliben eliben at gmail.com
Thu Aug 21 01:12:38 EDT 2008


On Aug 21, 4:51 am, Dave Benjamin <ra... at lackingtalent.com> wrote:
> Christian Heimes wrote:
> > eliben wrote:
> >> Ruby's 'Scruct' class (http://ruby-doc.org/core/classes/Struct.html)
> >> does this. I suppose it can be done with 'exec', but is there a more
> >> Pythonic way ?
>
> > Try named tuplehttp://code.activestate.com/recipes/500261/
>
> > A named tuple implementation is part of Python 2.6 and 3.0. For older
> > versions of Python use the recipe from activestate.
>
> Whaaa? Named tuples are being added to Python? Neat! Is there any
> documentation on this? I can't seem to find anything on the web...
>

It's not easy to find unless you recall where you've seen it:
http://docs.python.org/dev/3.0/library/collections.html#collections.namedtuple




More information about the Python-list mailing list