[Tutor] sys.argv[1: ] help
uselinux34 at yahoo.co.uk
Sun Feb 27 18:55:54 CET 2005
No What I get if I was to type in
./arg1.py a b c
All I get is
If i type at the command prompt
python arg1.py a b c
I get ['a','b','c'] as expected
All the other programs and examples I have typed in work fine just by
typing in the file name, I don't have to preced the file name with
python, only this example. I hope this makes it clearer
Nick Lunt wrote:
>if you try to print sys.argv[1:] when sys.argv only contain sys.argv
>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.
>$ cat 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.
>>Tutor maillist - Tutor at python.org
>Tutor maillist - Tutor at python.org
More information about the Tutor