[issue40202] Misleading grammatically of ValueError Message?

Steven D'Aprano report at bugs.python.org
Mon Apr 6 05:51:57 EDT 2020


Steven D'Aprano <steve+python at pearwood.info> added the comment:

I think the error messages could be improved.

In the first example: `f,x, a, b = [1,2,3]`

you are unpacking three values, but you need to unpack 4. The error message is not very helpful: 5 values is "more than 3" but it would be too many, you need not "more than 3" but exactly 4.

In the second example `a, b = [1,2,3]` it would be nice if it would tell you how many values you need to unpack.

Ideally, the message would say something like:

    Need to unpack 4 values but got 3  # first example
    Need to unpack 2 values but got 3  # second example

However I don't know if this is possible with the current parser, it might not be possible until the parser is changed (maybe in 3.9?)

----------
nosy: +steven.daprano

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40202>
_______________________________________


More information about the Python-bugs-list mailing list