script that parses command line, and execfile('')

TP Tribulations at Paralleles.invalid
Mon Nov 3 14:18:35 EST 2008


Hello,

I have a script that uses the "optparse" package to parse the command line.
For example:

$ script.py --help
# displays help about script.py

Is this possible to call such a script with execfile('') once in the Python
interactive shell?

>>> execfile( 'script.py' )

I get errors because there is no argv dictionary when used with execfile.

How to solve this problem, so that I am able to use script.py in command
line as well as with execfile?

Thanks

Julien

-- 
python -c "print ''.join([chr(154 - ord(c)) for c in '*9(9&(18%.9&1+,\'Z
(55l4('])"

"When a distinguished but elderly scientist states that something is
possible, he is almost certainly right. When he states that something is
impossible, he is very probably wrong." (first law of AC Clarke)



More information about the Python-list mailing list