Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!tudelft.nl!txtfeed1.tudelft.nl!multikabel.net!newsfeed20.multikabel.net!news2.euro.net!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'string.': 0.04; 'python': 0.08; '>>>>': 0.09; 'beating': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'throw': 0.09; 'underlying': 0.09; 'valueerror:': 0.09; 'subject:error': 0.09; 'exception': 0.12; 'debugging': 0.13; 'enigma': 0.16; 'kern': 0.16; 'paths.': 0.16; 'rhs': 0.16; 'roy': 0.16; 'unpack': 0.16; 'wrote:': 0.18; '(most': 0.21; 'maybe': 0.21; 'header:In-Reply-To:1': 0.22; 'changed': 0.23; 'string': 0.24; 'traceback': 0.24; 'interpret': 0.29; 'problem': 0.29; 'pm,': 0.29; '(the': 0.30; 'does': 0.32; 'values': 0.32; 'header:User-Agent:1': 0.33; 'header:X-Complaints- To:1': 0.33; 'to:addr:python-list': 0.34; 'too': 0.34; 'last):': 0.34; 'totally': 0.35; 'file': 0.36; 'but': 0.37; "there's": 0.37; 'spent': 0.38; 'received:org': 0.38; 'some': 0.38; 'should': 0.39; 'why': 0.39; 'help': 0.39; "it's": 0.40; 'to:addr:python.org': 0.40; 'your': 0.61; 'world': 0.62; 'received:86': 0.63; 'our': 0.64; 'believe': 0.65; 'subject:day': 0.68; "'foo'": 0.84; 'eco': 0.91; 'man,': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Robert Kern Subject: Re: Misleading error message of the day Date: Thu, 08 Dec 2011 14:47:02 +0000 References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: host86-183-157-196.range86-183.btcentralplus.com User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:8.0) Gecko/20111105 Thunderbird/8.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 34 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1323355640 news.xs4all.nl 6925 [2001:888:2000:d::a6]:55913 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:16832 On 12/8/11 2:23 PM, Roy Smith wrote: > I just spent a while beating my head against this one. > > # Python 2.6 >>>> a, b = 'foo' > Traceback (most recent call last): > File "", line 1, in > ValueError: too many values to unpack > > The real problem is that there's too *few* values to unpack! It should > have been > > a, b = 'foo', 'bar' > > I understand why it's generating the exception it does (the string is an > iterable), but man, did that message throw off my thought processes and > lead me down some totally bogus debugging paths. > > It's an unusual case to want to unpack a string. Maybe the message > should changed to "too {many, few} values to unpack (are you sure you > wanted to unpack a string?)" if the RHS is a basestring? Would including the respective numbers help your thought processes? ValueError: too many values to unpack (expected 2, got 3) -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco