Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'example:': 0.03; 'value,': 0.04; 'raised': 0.07; 'correct.': 0.09; 'not?': 0.09; 'reply- to:addr:comp.lang.python': 0.09; 'to:addr:comp.lang.python': 0.09; 'valueerror:': 0.09; 'subject:error': 0.09; 'exception': 0.12; 'def': 0.13; '"expected': 0.16; 'unpack': 0.16; 'cc:addr:python- list': 0.16; 'wrote:': 0.18; 'cc:no real name:2**0': 0.20; '(most': 0.21; 'header:In-Reply-To:1': 0.22; 'cc:2**0': 0.24; 'traceback': 0.24; 'saying': 0.26; 'fact': 0.27; 'yield': 0.29; 'print': 0.29; 'cc:addr:python.org': 0.29; '(as': 0.31; 'values': 0.32; 'header:User-Agent:1': 0.33; 'too': 0.34; 'last):': 0.34; 'file': 0.36; 'gotten': 0.37; 'thursday,': 0.37; 'skip:" 10': 0.37; 'but': 0.37; 'received:google.com': 0.37; 'received:209.85': 0.38; 'returned': 0.39; 'why': 0.39; 'help': 0.39; "it's": 0.40; 'third': 0.40; 'received:209': 0.40; 'might': 0.40; 'more': 0.61; '2011': 0.61; 'your': 0.61; 'subject:day': 0.68; 'kept': 0.68; 'header:Reply-To:1': 0.71; 'reply-to:no real name:2**0': 0.72; 'reply-to:addr:googlegroups.com': 0.74; 'going,': 0.84; 'received:209.85.216.184': 0.84; 'received:mail- qy0-f184.google.com': 0.84 Newsgroups: comp.lang.python Date: Thu, 8 Dec 2011 07:42:46 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.114.87.114; posting-account=dAOV_goAAABEUkqpkMcBZ68KkIzfCnsO References: User-Agent: G2/1.0 X-Google-Web-Client: true MIME-Version: 1.0 Subject: Re: Misleading error message of the day From: Roy Smith To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: comp.lang.python@googlegroups.com List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Message-ID: Lines: 32 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1323358974 news.xs4all.nl 6900 [2001:888:2000:d::a6]:42713 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:16841 On Thursday, December 8, 2011 10:16:56 AM UTC-5, Heiko Wundram wrote: > Am 08.12.2011 15:47, schrieb Robert Kern: > > Would including the respective numbers help your thought processes? > > ValueError: too many values to unpack (expected 2, got 3) >=20 > Not possible in the general case (as the right-hand side might be an=20 > arbitrary iterable/iterator...). Why not? Take this example: def i(): i =3D 0 while True: print "returning:", i yield i i +=3D 1 a, b =3D i() ./iter.py returning: 0 returning: 1 returning: 2 Traceback (most recent call last): File "./iter.py", line 10, in a, b =3D i() ValueError: too many values to unpack The exception was raised when i() returned it's third value, so saying "exp= ected 2, got 3" is exactly correct. Yes, it is true that it might have got= ten more if it kept going, but that's immaterial; the fact that it got to 3= is what caused the Holy Hand Grenade to be thrown.