empty classes as c structs?

Christopher J. Bottaro cjbottaro at alumni.cs.utexas.edu
Fri Feb 4 13:59:01 EST 2005


I find myself doing the following very often:

class Struct:
        pass
...
blah = Struct()
blah.some_field = x
blah.other_field = y
...

Is there a better way to do this?  Is this considered bad programming
practice?  I don't like using tuples (or lists) because I'd rather use
symbolic names, rather than numeric subscripts.  Also, I don't like having
to declare the empty Struct class everytime I want to do this (which is
very often).

Feedback is appreciated, thanks.




More information about the Python-list mailing list