Overriding a function...

K.S.Sreeram sreeram at tachyontech.net
Mon Jun 19 15:32:15 EDT 2006


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 'import mymodule' and then use 'mymodule.test' to access the
function, then they'll see the new 'override' function.

Alternatively, If you do 'from mymodule import test', and use 'test',
then they'll see the original 'test' function.

Regards
Sreeram

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 260 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20060620/e26dad89/attachment.sig>


More information about the Python-list mailing list