creating a file from python

Joshua Schmidlkofer menion at asylumwear.com
Wed Jul 3 00:36:58 EDT 2002


gollem wrote:

>I want to create a file from inside a running python script.
>I can do that using commands and touch but it won't work if the intended
>name of the file is the value of a python variable. The file is created as
>the variable name instead of the variable value.
>I think I need to use a shell (bash) variable to do it but then the question
>becomes how do I create that? thnx
>
>
>  
>



I think you mean:

import os

os.environ['MYFILE'] = 'myfilename'
os.system('bash -c "myscript_that_needs_a_variable_named_MYFILE")




js







More information about the Python-list mailing list