Suppose I have a Python class that I want to add an extra property to.
Is there any difference between
import path.MyClass
MyClass.foo = bar
and using something like :
import path.MyClass
setattr(MyClass, 'foo', bar)
?
If not, why do people seem to do the second rather than the first? (Eg. here http://concisionandconcinnity.blogspot.com/2008/10/chaining-monkey-patches-in-python.html )