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


Groups > comp.lang.python > #41932

Re: problem with sys import argv

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.04; '"""': 0.07; 'error:': 0.07; 'sys': 0.07; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'valueerror:': 0.09; 'python': 0.11; 'wrote': 0.14; '"i\'d': 0.16; '%r.': 0.16; "%s'": 0.16; '%s,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'script,': 0.16; 'skip:" 70': 0.16; 'subject:import': 0.16; 'unpack': 0.16; 'wrote:': 0.18; 'community,': 0.19; 'import': 0.22; 'print': 0.22; 'header:User- Agent:1': 0.23; 'error': 0.23; 'subject:problem': 0.24; 'url:moin': 0.24; 'script': 0.25; 'handling': 0.26; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'url:wiki': 0.31; 'username': 0.31; 'file': 0.32; 'thanks!': 0.32; 'run': 0.32; 'url:python': 0.33; '(most': 0.33; 'computer.': 0.33; 'subject:with': 0.35; 'url:org': 0.36; 'being': 0.38; 'to:addr :python-list': 0.38; 'recent': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'read': 0.60; 'is.': 0.60; "you're": 0.61; 'kind': 0.63; 'more': 0.64; 'charset:windows-1252': 0.65; 'prompt': 0.68; 'lives': 0.74; 'liking': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Mark Lawrence <breamoreboy@yahoo.co.uk>
Subject Re: problem with sys import argv
Date Tue, 26 Mar 2013 17:42:09 +0000
References <A33EC90F-DEC4-424D-BDBF-68165669A336@icloud.com>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 8bit
X-Gmane-NNTP-Posting-Host host-92-18-20-125.as13285.net
User-Agent Mozilla/5.0 (Windows NT 6.0; rv:17.0) Gecko/20130307 Thunderbird/17.0.4
In-Reply-To <A33EC90F-DEC4-424D-BDBF-68165669A336@icloud.com>
X-Antivirus avast! (VPS 130325-2, 25/03/2013), Outbound message
X-Antivirus-Status Clean
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3763.1364319509.2939.python-list@python.org> (permalink)
Lines 46
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1364319509 news.xs4all.nl 6906 [2001:888:2000:d::a6]:51567
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:41932

Show key headers only | View raw


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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web