Catching errors in attribute names at assigment

Thomas Philips tkpmep at
Mon Jun 21 20:00:14 CEST 2004

If one makes a typographical error when assigning a value to an
attribute (i.e if one types ClassName.xyc = 10 instead of, 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

Thomas Philips

More information about the Python-list mailing list