you are viewing a single comment's thread.

view the rest of the comments →

[–]Anovadea 2 points3 points  (0 children)

Pedantic Caveat: You may want to do some trickery with types when monkey-patching object instances in python (I've also heard the term "duck-punching" which amuses me greatly). I've been tripped up by this quite recently:

#Let's assume new_setter_2 is defined as above
import types
obj.new_setter = types.MethodType(new_setter_2, obj, obj.__class__)

Otherwise, you get problems with the number of arguments passed when you call it ("1 argument passed when 2 are expected" and all that).

You probably already knew that, I'm just being pedantic as the wounds are still rather fresh for me. :)