Catching errors in attribute names at assigment

Thomas Philips tkpmep at hotmail.com
Mon Jun 21 14:00:14 EDT 2004


If one makes a typographical error when assigning a value to an
attribute (i.e if one types ClassName.xyc = 10 instead of
ClassName.xyz=10), a new attribute xyc will be created, and the error
can later prove difficult to debug.

Is there a way to check assignments when they are made and to allow
only those that modify a restricted set of allowable attributes?
Looking through ClassName.__dict__.keys() is perhaps one way to
achieve this: Is there a simpler (i.e. more Pythonic) way to do it as
well?

Thomas Philips



More information about the Python-list mailing list