Factory for Struct-like classes
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Mon Aug 18 05:16:41 EDT 2008
More information about the Python-list mailing list
Mon Aug 18 05:16:41 EDT 2008
- Previous message (by thread): Factory for Struct-like classes
- Next message (by thread): Factory for Struct-like classes
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 13 ago, 14:46, eliben <eli... at gmail.com> wrote: > On Aug 13, 7:30 pm, Christian Heimes <li... at cheimes.de> 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/ > > 1) I see this is done with exec anyway, so there's no more pythonic > way. It doesn't *have* to be done with exec - I think there are other variants using metaclasses instead. > 2) The definition of fields as a single string is weird. Why not use > **kwargs instead ? Because the field ordering would be lost, which is important for a named *tuple*. (Anyway, I'd prefer a list of names instead of a single string...) -- Gabriel Genellina
- Previous message (by thread): Factory for Struct-like classes
- Next message (by thread): Factory for Struct-like classes
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list