passing command line arguments

Brian McCann Brian.McCann at viziant.net
Fri Sep 7 20:11:14 CEST 2007


 
Darren,
Thanks
 

________________________________

From: python-list-bounces+brian.mccann=viziant.net at python.org on behalf of darren kirby
Sent: Fri 9/7/2007 1:58 PM
To: python-list at python.org
Subject: Re: passing command line arguments



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
--
http://mail.python.org/mailman/listinfo/python-list


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070907/6cf5bf91/attachment.html>


More information about the Python-list mailing list