Destroy Object Method After First Invocation
I have already figured out the answer to that, so I am placing it here as a question to myself - for the sake of those that may come up with similar question. Basically, I wanted t
Solution 1:
OK, the answer was - delete method at the class level - which suits my need
In [195]: class Child(Parent):
def place_for_action(self):
super(Child, self).place_for_action()
print 'This is child'
delattr(self.__class__, 'place_for_action')
.....:
Works like charm
In [196]: c = Child()
In [197]: c.place_for_action()
This is parent
This is child
In [198]: c.place_for_action()
This is parent
Post a Comment for "Destroy Object Method After First Invocation"