cmdline args to a piped python prog

Piet van Oostrum piet at cs.uu.nl
Wed Mar 10 05:48:57 EST 2004


>>>>> "leo" <halloleo at noospaam.myrealbox.com> (L) wrote:

L> hi there
L> a python file can evaluate cmdline arguments like

L> python myprog.py arg1 arg2 arg3...

L> when i feed python with my program via terminal input like

L> cat myprog.py | python

L> how can i then specifiy the cmdline arguments arg1 arg2 arg3...?

You could say cat myprog.py | python - arg1 arg2 arg3
Then sys.argv[1:] contains the arguments.

By the way cat myprog.py | python * is equivalent to python * < myprog.py
No need for cat.
-- 
Piet van Oostrum <piet at cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: P.van.Oostrum at hccnet.nl



More information about the Python-list mailing list