[Tutor] sys.argv[1: ] help
Nick Lunt
nick at javacat.f2s.com
Sun Feb 27 18:05:49 CET 2005
Richard,
if you try to print sys.argv[1:] when sys.argv only contain sys.argv[0]
then you are bound to get an empty list returned, [] .
Im not sure I understand the problem you think you've got but here's
what happens with sys.argv for me, and it's correct.
[argl.py]
$ cat argl.py
#!/usr/bin/python
import sys
print sys.argv[1:]
./argl.py
[]
./argl.py a b c
['a', 'b', 'c']
Is that what your getting ?
> Sorry for the late response, I tried all of the the suggestions,
> including correcting my typo of print sys[1:] and tried print
> sys,argv[1:], this does now work as long as I run 'python test.py fred
> joe' it returns all the arguments. If I try just test.py all I get is
> '[]' . Is there something wrong with my environmental variables in
> Windows XP, I would like to be able to just use the file name rather
> than having to type python each time. Any help would be gratefully received.
>
> Richard G.
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list