[Tutor] sys.argv[1: ] help

Richard gelling uselinux34 at yahoo.co.uk
Fri Feb 25 22:35:57 CET 2005


I am reading ' Learning Python second edition' by Mark Lutz and David 
Ascher, and  I trying the code examples as  I go along. However I am 
having a problem with the following, which I don't seem to be able to 
resolve :-

# test.py
import sys

print sys[ 1: ]

This I believe is supposed to print the 1st argument passed to the 
program. However if I try

test.py fred

All  I get at the command line is


If I try :-

python test.py fred

I get


as I believe you are supposed to. I can run other examples,I have typed 
in by just using the file name, but not this particular example. Could 
anyone shine any light on what I am missing or have not configured 
correctly. I am runnung Python 2.4 on a windows XP box.

Thanks a lot

Richard G.

More information about the Tutor mailing list