Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #41932 > unrolled thread

Re: problem with sys import argv

Started byMark Lawrence <breamoreboy@yahoo.co.uk>
First post2013-03-26 17:42 +0000
Last post2013-03-26 17:42 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: problem with sys import argv Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-03-26 17:42 +0000

#41932 — Re: problem with sys import argv

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2013-03-26 17:42 +0000
SubjectRe: problem with sys import argv
Message-ID<mailman.3763.1364319509.2939.python-list@python.org>
On 26/03/2013 17:26, leonardo selmi wrote:
> hi python community,
>
> i wrote the following programm:
>
> from sys import argv
>
> script, userName = argv
> prompt = '> '
>
> print 'hi %s, i am the %s script' % (userName, script)
> print "i'd like to ask you a few questions."
> print 'do you like me %s' % userName
> likes = raw_input(prompt)
>
> print "where do you live %s?" % userName
> lives = raw_input(prompt)
>
> print 'what kind of computer do you have?'
> computer = raw_input(prompt)
>
> print """
> alright so you said %r about liking me.
> you live in %r. not sure where that is.
> and you have a %r computer. nice
> """ % (likes, lives, computer)
>
> and i got the following error:  Traceback (most recent call last):
> File "/var/folders/89/84z7tw3d3rv39gny3n2p963m0000gn/T/pythonInTerm.GUF6PWCM", line 3, in <module>
>    script, userName = argv
> ValueError: need more than 1 value to unpack
>
> what can i do?
>
> thanks!
>

Write some error handling to allow for the script being run without the 
user name.

-- 
If you're using GoogleCrap™ please read this 
http://wiki.python.org/moin/GoogleGroupsPython.

Mark Lawrence

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web