Override a method in another module

Brian Quinlan brian at sweetapp.com
Tue Oct 1 18:42:59 EDT 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
F.
> 
> 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

Cheers,
Brian





More information about the Python-list mailing list