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


Groups > comp.lang.python > #16833

Re: Misleading error message of the day

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!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <prvs=316c4d627=jeanmichel@sequans.com>
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; 'correct.': 0.09; 'throw': 0.09; 'valueerror:': 0.09; 'subject:error': 0.09; 'exception': 0.12; 'debugging': 0.13; 'a,b,c': 0.16; 'iterable,': 0.16; 'paths.': 0.16; 'rhs': 0.16; 'roy': 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; 'maybe': 0.21; 'header:In-Reply-To:1': 0.22; 'changed': 0.23; 'string': 0.24; 'cc:2**0': 0.24; 'traceback': 0.24; 'problem': 0.29; 'print': 0.29; 'cc:addr:python.org': 0.29; 'error': 0.29; '(the': 0.30; 'does': 0.32; 'values': 0.32; 'header :User-Agent:1': 0.33; 'too': 0.34; 'last):': 0.34; 'totally': 0.35; 'file': 0.36; 'but': 0.37; "there's": 0.37; 'spent': 0.38; 'some': 0.38; 'should': 0.39; 'why': 0.39; "it's": 0.40; 'subject:day': 0.68; 'received:62': 0.70; "'f',": 0.84; "'foo'": 0.84; 'man,': 0.91
X-IronPort-AV E=Sophos;i="4.71,320,1320620400"; d="scan'208";a="36381"
X-Virus-Scanned amavisd-new at zimbra.sequans.com
Date Thu, 08 Dec 2011 16:03:38 +0100
From Jean-Michel Pichavant <jeanmichel@sequans.com>
User-Agent Mozilla-Thunderbird 2.0.0.24 (X11/20100328)
MIME-Version 1.0
To Roy Smith <roy@panix.com>
Subject Re: Misleading error message of the day
References <roy-9DEDD9.09233308122011@news.panix.com>
In-Reply-To <roy-9DEDD9.09233308122011@news.panix.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
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.3415.1323356627.27778.python-list@python.org> (permalink)
Lines 35
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1323356627 news.xs4all.nl 6964 [2001:888:2000:d::a6]:54757
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:16833

Show key headers only | View raw


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 "<stdin>", line 1, in <module>
> 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?
>   
string are iterable, considering this, the error is correct.

Values to unpack in 'foo' are 'f', 'o', 'o'

 > a,b,c = 'foo'

 > print a,b,c
f o o


JM

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


Thread

Misleading error message of the day Roy Smith <roy@panix.com> - 2011-12-08 09:23 -0500
  Re: Misleading error message of the day Andrea Crotti <andrea.crotti.0@gmail.com> - 2011-12-08 14:39 +0000
  Re: Misleading error message of the day Chris Angelico <rosuav@gmail.com> - 2011-12-09 01:40 +1100
  Re: Misleading error message of the day Robert Kern <robert.kern@gmail.com> - 2011-12-08 14:47 +0000
    Re: Misleading error message of the day Roy Smith <roy@panix.com> - 2011-12-08 07:30 -0800
      Re: Misleading error message of the day Tim Chase <python.list@tim.thechases.com> - 2011-12-08 11:41 -0600
    Re: Misleading error message of the day Roy Smith <roy@panix.com> - 2011-12-08 07:30 -0800
  Re: Misleading error message of the day Jean-Michel Pichavant <jeanmichel@sequans.com> - 2011-12-08 16:03 +0100
    Re: Misleading error message of the day Roy Smith <roy@panix.com> - 2011-12-08 07:33 -0800
      Re: Misleading error message of the day Jean-Michel Pichavant <jeanmichel@sequans.com> - 2011-12-08 20:49 +0100
      Re: Misleading error message of the day Ethan Furman <ethan@stoneleaf.us> - 2011-12-08 12:13 -0800
      Re: Misleading error message of the day Lie Ryan <lie.1296@gmail.com> - 2011-12-09 12:46 +1100
        Re: Misleading error message of the day alex23 <wuwei23@gmail.com> - 2011-12-08 20:57 -0800
          Re: Misleading error message of the day Lie Ryan <lie.1296@gmail.com> - 2011-12-11 10:41 +1100
      Re: Misleading error message of the day Jean-Michel Pichavant <jeanmichel@sequans.com> - 2011-12-09 11:03 +0100
        Re: Misleading error message of the day Roy Smith <roy@panix.com> - 2011-12-09 09:43 -0500
      Re: Misleading error message of the day Ethan Furman <ethan@stoneleaf.us> - 2011-12-09 09:39 -0800
    Re: Misleading error message of the day Roy Smith <roy@panix.com> - 2011-12-08 07:33 -0800
      Re: Misleading error message of the day Grant Edwards <invalid@invalid.invalid> - 2011-12-08 18:10 +0000
        Re: Misleading error message of the day alister <alister.ware@ntlworld.com> - 2011-12-08 20:58 +0000
          Re: Misleading error message of the day Chris Angelico <rosuav@gmail.com> - 2011-12-09 08:17 +1100
        Re: Misleading error message of the day Roy Smith <roy@panix.com> - 2011-12-08 20:19 -0500
        Re: Misleading error message of the day Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-09 02:07 +0000
          Re: Misleading error message of the day Chris Angelico <rosuav@gmail.com> - 2011-12-09 14:46 +1100
            Re: Misleading error message of the day Roy Smith <roy@panix.com> - 2011-12-08 23:44 -0500
  Re: Misleading error message of the day Heiko Wundram <modelnine@modelnine.org> - 2011-12-08 16:16 +0100
    Re: Misleading error message of the day Roy Smith <roy@panix.com> - 2011-12-08 07:42 -0800
      Re: Misleading error message of the day Heiko Wundram <modelnine@modelnine.org> - 2011-12-08 16:50 +0100
        Re: Misleading error message of the day Roy Smith <roy@panix.com> - 2011-12-08 10:42 -0800
          Re: Misleading error message of the day Benjamin Kaplan <benjamin.kaplan@case.edu> - 2011-12-08 13:57 -0500
          Re: Misleading error message of the day Ethan Furman <ethan@stoneleaf.us> - 2011-12-08 11:09 -0800
          Re: Misleading error message of the day Benjamin Kaplan <benjamin.kaplan@case.edu> - 2011-12-08 14:38 -0500
          Re: Misleading error message of the day Ethan Furman <ethan@stoneleaf.us> - 2011-12-08 12:09 -0800
        Re: Misleading error message of the day Roy Smith <roy@panix.com> - 2011-12-08 10:42 -0800
      Re: Misleading error message of the day Andrea Crotti <andrea.crotti.0@gmail.com> - 2011-12-08 15:55 +0000
      Re: Misleading error message of the day Chris Angelico <rosuav@gmail.com> - 2011-12-09 03:21 +1100
      Re: Misleading error message of the day Robert Kern <robert.kern@gmail.com> - 2011-12-08 19:57 +0000
    Re: Misleading error message of the day Roy Smith <roy@panix.com> - 2011-12-08 07:42 -0800

csiph-web