Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'string.': 0.04; 'python': 0.08; '>>>>': 0.09; 'beating': 0.09; 'throw': 0.09; 'valueerror:': 0.09; 'subject:error': 0.09; 'exception': 0.12; 'debugging': 0.13; 'paths.': 0.16; 'rhs': 0.16; 'roy': 0.16; 'unpack': 0.16; 'cc:addr :python-list': 0.16; 'received:74.125.82.44': 0.16; 'received :mail-ww0-f44.google.com': 0.16; "wouldn't": 0.17; 'wrote:': 0.18; 'string,': 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; 'cc:addr:python.org': 0.29; 'pm,': 0.29; '(the': 0.30; 'does': 0.32; 'values': 0.32; 'list': 0.32; 'message- id:@gmail.com': 0.33; 'header:User-Agent:1': 0.33; 'actually': 0.33; 'too': 0.34; 'last):': 0.34; 'received:74.125.82': 0.35; 'totally': 0.35; 'file': 0.36; 'but': 0.37; 'passed': 0.37; 'received:74.125': 0.37; 'received:google.com': 0.37; "there's": 0.37; 'received:10.0.0': 0.38; 'spent': 0.38; 'some': 0.38; 'should': 0.39; 'why': 0.39; "it's": 0.40; 'worth': 0.61; 'subject:day': 0.68; "'foo'": 0.84; '02:23': 0.84; 'man,': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=QP3AqUdhTEwPxXSkpFlbPsijd5r6/iwHDACk6Omd+uk=; b=FerfQNlLYncNBYW5qEHcMlntV3TrdnriuaX9ZoN5nPKIob9GgVXQVnE34GUfPECigC Ek14G3s9VYaoV7J2B+9pDU43lZFhNmaRSh7hYvIjOG3mwe5fuUoLZxydrs2N6ZAXOEjO oYAPI9ZwxfXV1PRtCpc1uuQQJ2cOjXvGFmxuQ= Date: Thu, 08 Dec 2011 14:39:27 +0000 From: Andrea Crotti User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20111108 Thunderbird/8.0 MIME-Version: 1.0 To: Roy Smith Subject: Re: Misleading error message of the day References: In-Reply-To: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1323355172 news.xs4all.nl 6895 [2001:888:2000:d::a6]:50729 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:16830 On 12/08/2011 02: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? I had a few errors sometimes because I thought I passed in a list while I passed only a string, which since it's still iterable would just work but explode later. A nicer message wouldn't have really actually helped though, not sure it's worth to make an exception for such a thing..