import and function question

Moray Taylor mtaylor at lowebroadway.com
Mon Apr 8 05:55:21 EDT 2002


Hi,

I have two questions..

a) Can I 'import' a module with the full path, i.e. I don't want to
add it to sys.path, just something like 'import /home/me/mod.py', is
this possible.
I have tried adding it to the path, importing, and immediatly removing
it from the path, but the next time I do an 'import' with a different
module of the same name, it picks up the old one, even though it isn't
in the sys.path.

b) I need to overwrite a function with a new one of the same name, but
'import'ed from a module. Is this possible, I really just need to
destroy this function before I import the new one, can this be done?

The reason I want to do these peculiar things, is for a plugin system,
where there are lots of plugin.py files, but in different directories.

Thanks for any help on this.

Moray



More information about the Python-list mailing list