[Tutor] passing in string from command line

Kelly, Phelim KellyPhe@logica.com
Thu, 6 Dec 2001 17:46:07 -0000

Another Basic enough question I hope you can help with!

I'm reading in values from the command line that I want to assign to
variables within the code, i.e

>>python file.py number word

I know how to pass the typed number into a variable, i.e,

   variable1 =int(sys.argv[1])
   print "Sorry, but you did not enter a number"

What's the equivalent to "variable1 =int(sys.argv[1])" for assigning the
entered word to a variable, something like this??????........
"variable2 =string(sys.argv[2])"

Thanks in advance.


This e-mail and any attachment is for authorised use by the intended recipient(s) only.  It may contain proprietary material, confidential information and/or be subject to legal privilege.  It should not be copied, disclosed to, retained or used by, any other party.  If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender.  Thank you.