Override a method in another module

Brian Quinlan brian at sweetapp.com
Wed Oct 2 00:42:59 CEST 2002

> What's the basic syntax to override (redefine) a function in another
> module at runtime?
> Say, I have module M, class C, method F, and I want to redifine method
> setattr( M.C.F, eval("def F(self): pass"))  doesn't exactly work.....

You are working too hard:

def F(self): pass

M.C.F = F


More information about the Python-list mailing list