passing command line arguments

darren kirby bulliver at badcomputer.org
Fri Sep 7 19:58:35 CEST 2007


quoth the Brian McCann:
> Hi,
>
> when I run the script show_args2.py
>
> # ./show_args2.py 1 2 3
>
> I get the following error
>
> Traceback (most recent call last):
>   File "./show_args2.py", line 4, in ?
>     print 'The arguments of %s are "%s"' %s \
>     NameError: name 's' is not defined
>
>
> #####################################
> <mailto:brian.mccann at viziant.net>
> this is the script
>  #!/usr/bin/python
> import sys, string
> print 'The arguments of %s are "%s"' %s \
>         (sys.argv[0], string.join(sys.argv[1:]))

You don't want the 's' on the last format operator. Try:

 print 'The arguments of %s are "%s"' % \
         (sys.argv[0], string.join(sys.argv[1:]))

> any help would be greatly appreciated
>
> -Brian

-d
-- 
darren kirby :: Part of the problem since 1976 :: http://badcomputer.org
"...the number of UNIX installations has grown to 10, with more expected..."
- Dennis Ritchie and Ken Thompson, June 1972



More information about the Python-list mailing list