> Imports happen at run time. Beware starting threads in the code run at
> import time in each module, though - there are some nasty bugs lurking
> there. Instead, start the threads in functions invoked from the main
> routine.
I have run into trouble trying to do that before. Thanks for the
remi
Devan, would ...
__import__(name) for name in module_names
have worked just as well - without the equate to modules? or is the
modules list required as a hook for the imports ?
--
http://mail.python.org/mailman/listinfo/python-list
"David Poundall" <[EMAIL PROTECTED]> writes:
> I have several .py files in a directory that I would like to import at
> run time. Each file contains a state machine that requires to be run
> in its own thread.
Imports happen at run time. Beware starting threads in the code run at
import time in e
http://www.python.org/doc/2.4.2/lib/built-in-funcs.html
or, if you want an answer in code now and don't want to read the docs
def my_import(name):
module = __import__(name)
globals()[name] = module #not a good idea
Or, seeing as how you won't be directly accessing them by name, anyways
Thanks James, just after I posted I stumbled across the execfile
command. Looks like with 'exec' and 'execfile' I should be able to do
what I want.
What an elegant language.
--
http://mail.python.org/mailman/listinfo/python-list
exec "import something"
On Monday 24 October 2005 21:53, David Poundall wrote:
> I have several .py files in a directory that I would like to import at
> run time. Each file contains a state machine that requires to be run
> in its own thread.
>
> The first problem I have is how can I import the
I have several .py files in a directory that I would like to import at
run time. Each file contains a state machine that requires to be run
in its own thread.
The first problem I have is how can I import the code in all of the .py
files without knowing the file names in advance.
Can this be done