A class for C-like structuures in Python

Thomas Gagne tgagne at ix.netcom.com
Wed Aug 9 12:28:14 EDT 2000


I don't think I should be using __dict__, __getattr() and __setattr().  The
problem is it seems to internalize the member list as though they were fields
inside the structure.  This could be fine except that a) I can't get it
working (see previous message) and b) what if the variables defined conflict
with variables that are part of the class hierarchy?  Suppose someone wanted
to name a variable __str__ for whatever reason, this could be bad in Python.
But holding a dictionary entry for "__str__" wouldn't.

Having to code IsdHeader.valueFor('len') instead of the shorter IsdHeader.len
may be a tad awkward, but it should work in all circumstances, no?




More information about the Python-list mailing list