Overriding a function...

2006-06-19 Thread [EMAIL PROTECTED]
Suppose I have this module `mymodule.py' - # mymodule.py - begin def test(): print original # mymodule.py - end Now assume that I do this in some arbitrary module - def override(): print test is overridden import mymodule mymodule.test = override Two questions - 1) If mymodule is

Re: Overriding a function...

2006-06-19 Thread Marc 'BlackJack' Rintsch
In [EMAIL PROTECTED], [EMAIL PROTECTED] wrote: 1) If mymodule is subsequently imported, will my `override' function be used, or will python magically `fix' (or break depending on your perspective) mymodule and use the original mymodule.test function? It will not `fix` it. Importing an

Re: Overriding a function...

2006-06-19 Thread [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote: Suppose I have this module `mymodule.py' - # mymodule.py - begin def test(): print original # mymodule.py - end Now assume that I do this in some arbitrary module - def override(): print test is overridden import mymodule mymodule.test = override

Re: Overriding a function...

2006-06-19 Thread K.S.Sreeram
Marc 'BlackJack' Rintsch wrote: 2) Once I assign mymodule.test with override, will modules that imported my module *PRIOR* to the assignment get override, or will they keep the original function test()? They see the `override()` function. That depends on how the import was done. If you do