creating python code with dynamic file name
Dave Angel
davea at ieee.org
Fri May 15 08:33:32 EDT 2009
bijoy franco wrote:
> hi,
>
>
> How can i create python code, for which filename can be defined on the
> fly..?
>
> for example, in a blog, when each article selected, respective python code
> with headline of the article as filename should be called.
>
> thanks
>
> bijoy
>
>
You could have been much clearer in your requirements. I have to guess:
Perhaps you're writing a CGI script to run on Linux, with Python 2.3.
You need to be able to import a different python file, depending on some
data calculation. You have three different such python files, whose
names are known ahead of time.
if data == "English":
import english
elif data == "Spanish":
import spanish
else:
import nativeamerican
Or is it:
You're writing a script on Windows Server 2003, that's going to generate
python 3.0 source code, and html, and the code and the html it generates
is dependent on some data retrieved from Yahoo stock quotes. The python
all has to be version 3.1
Supply your environment, your requirements, some example data, and some
test code that doesn't quite work. Then someone will probably be able
to point out the problem.
I could suggest you play with __import__() But of course that's not
available everywhere.
More information about the Python-list
mailing list