Factory for Struct-like classes

Christian Heimes lists at cheimes.de
Wed Aug 13 13:30:37 EDT 2008


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 tuple http://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.

Christian




More information about the Python-list mailing list