Question: Dynamic code import

Bjorn Pettersen BPettersen at NAREX.com
Thu Oct 25 17:43:20 EDT 2001


> From: Károly Ladvánszky [mailto:aa at bb.cc] 
> 
> Hi Bjorn,
> 
> Thanks for your quick answer. Yes, I was mistaken with the 
> global directive. It's clear now. Regarding the first 
> question, it works fine with the interpreter but I would like to read
> f11(a) from somewhere else, most likely from a file.

Hmmm... Not quite sure what you mean. Is it in a Python file, a text
file, ??

If it's in a Python file you can just import the module and assign to
the variable as before, if it's in a text file you'd need to use eval or
exec. Let us know which it is and I'm sure we could come up with
examples... :-)

-- bjorn




More information about the Python-list mailing list