I don\'t know for why using __setattr__ instead simple referencing like x.a=1.
I understand this example:
class Rectangle:
the __setattr__ can be used to reflection, where an propperty on the object Rectangle can be created at runtime, there are more about it on http://en.wikipedia.org/wiki/Reflection_%28computer_science%29
class Rectangle:
def __init__(self):
#... code ...
x = Rectangle()
#x.__setattr__('newProperty',30) Edited after comment
setattr(x, 'newProperty', 30)
print x.newProperty #>>> 30