[New-bugs-announce] [issue40202] Misleading grammatically of ValueError Message?

Jacob RR report at bugs.python.org
Mon Apr 6 04:16:14 EDT 2020


New submission from Jacob RR <xboxgamermaple at gmail.com>:

hi,

so I *think* that ValueError shows an error grammatically incorrect?
In python 2.7
>>> x = [1,2,3]
>>> f,x, a, b = [1,2,3]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: need more than 3 values to unpack

Should have said: Received 3 values to unpack ?
The problem with that is the list size is 3 and the error says that I need more than 3 values to unpack which is logically wrong **IMHO** (don't kill me if im mistaken)

Now if I try to do something else, for example:

>>> x = [1,2,3]
>>> a, b = [1,2,3]

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: too many values to unpack

It says **too many** but I assign a few than the size of the list. am I the one who wrong here?

Now, I code in Python 3 I'm not a professional  like you, I'm novice and try to learn.. I'll get to the point, the same code in Python 3.7.6 (Anaconda, pip is disappoint me :< )

>>> a = [1,2,3]
>>> x,y = a
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: too many values to unpack (expected 2)

Should said something else because it received less values and expected should say 3 and not 2, correct?


thanks for reading.




PS: Sorry I'm not a native speaker and I might be wrong and am very sorry if time wasted.

----------
assignee: docs at python
components: Documentation
messages: 365842
nosy: Jacob RR, docs at python
priority: normal
severity: normal
status: open
title: Misleading grammatically of ValueError Message?
type: enhancement
versions: Python 3.7

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


More information about the New-bugs-announce mailing list