Should be: import sys
def main(): '''prints out the first command line argument''' print sys.argv[1] main() On Friday 25 February 2005 04:35 pm, Richard gelling wrote: > Hi, > > 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 > > ['fred'] > > 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. > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor