equivalent of source <file> in python?

News123 news1234 at free.fr
Tue Aug 24 22:01:19 CEST 2010


On 08/24/2010 09:18 PM, Astan Chee wrote:
> Hi,
> I'm trying to convert my tcsh script to python and am stuck at one part,
> particularly the part of the script that looks like this:
> 
> #!/bin/tcsh
> setenv LSFLOG /var/tmp/lsf_log
> source /etc/setup
> unalias cp
> umask 0
> env >> ${AFLOG}
> 
> What is the equivalent of doing this in python2.5?
> Thanks again

the equivalent would be exec(), but I'm not sure, that it is a good idea
to try to make a
word by word translation of a shell script into python.


you could do
exec( open("/etc/setup").read() )

but of course you had to translate /etc/setup

to python.











More information about the Python-list mailing list