Override a method in another module
edgebruce at yahoo.com
Wed Oct 2 01:44:42 CEST 2002
Chris Liechti wrote:
> Bruce Edge <edgebruce at yahoo.com> wrote in
> news:Fppm9.30728$V64.5796737 at newsfeed.slurp.net:
>> 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.....
> and how does:
>>>> def F(self): pass
>>>> M.C.F = F #or setattr(M.C, 'F', F)
> 1) setattr needs 3 args
> 2) eval works only for expressions and "def" is a keyword
Woo Hoo!!! Works !! Thank you.
I can stop banging my head on my desk now.
More information about the Python-list