[Wolves] python module query
sparkes
sparkes at westmids.biz
Mon Sep 6 18:24:06 BST 2004
Stuart Langridge wrote:
> sparkes wrote:
>
>> exec 'import ' + <variable> + ' as my_mod'
>
>
> Eek. Don't do that.
>
> foo = __import__('foo')
you mean
foo = __import__(foo)
;-)
>
> Much neater. The exec() function is an evil sin. Any time you think of
> using it, there's likely to be a better way :)
cheers mate that is much clearer as well. I knew there was a simple way
of looking at it but could I find it.
incidentally I am using reload() to unload the module (this method is
later called again to load, run and unload other modules (except they
aren't really modules but python scripts in the same directory)), can
this really be right? It works but it doesn't look as readable as the
rest of the code do to the fact reload certainly doesn't mean unload in
english ;-)
>
> Aq.
>
sparkes
More information about the Wolves
mailing list