I see what you're attempting to do. However, your code, if it DID run, would result in a method being added to the object, not the object's class! Modify the class itself, not the object, as follows: |class Test: | def __init__(self): | self.method() | |def m(self): | print self | |setattr(Test, 'method', m) |Test()