Misleading error message of the day
Chris Angelico
rosuav at gmail.com
Thu Dec 8 09:40:53 EST 2011
On Fri, Dec 9, 2011 at 1:23 AM, Roy Smith <roy at panix.com> 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
Definitely weird! I smell a job for a linter though. If you had just
happened to have a two-character string there, it would have quietly
succeeded, and left you wondering what was going on - imho rather
worse.
This isn't something for the language to solve; the same issue would
come up if you had something like:
a=[1,2,3]
b=[4,5,6]
c,d=a # oops, mucked up the "a,b" side
Or any other iterable. Looks to me like a chance for an informational
note from your lint facility, not a change to the language.
ChrisA
More information about the Python-list
mailing list