On Sun, Mar 1, 2020 at 6:51 PM Christopher Barker <[email protected]>
wrote:
SNIP
the problem here is that "iterable unpacking" (is that what we call it
> now?) is pretty general, and used all over python.
> ValueError: too many values to unpack (expected 2)
>
> Which, in fact, is what iPython already does:
>
> In [5]: a,b = 1,2,3
>
> ---------------------------------------------------------------------------
> ValueError Traceback (most recent call last)
> <ipython-input-5-402193b14bdc> in <module>
> ----> 1 a,b = 1,2,3
>
> ValueError: too many values to unpack (expected 2)
>
> But not in the dict iterating case:
>
> In [2]: for key, val in d:
> ...: print(key, val)
> ...:
>
> ---------------------------------------------------------------------------
> ValueError Traceback (most recent call last)
> <ipython-input-2-8ac4fd3a14a8> in <module>
> ----> 1 for key, val in d:
> 2 print(key, val)
> 3
>
> ValueError: too many values to unpack (expected 2)
>
> (cause it's showing the line of code, not the run time values)
>
> So if possible, it would be great if error messages did generally show the
> value(s) of the objects involved, if possible.
>
This information is certainly retrievable - but not by standard consoles.
$ python -m friendly_traceback
Friendly Console version 0.0.28a. [Python version: 3.7.3]
>>> d = {"a": 1, "b": 2}
>>> for key, value in d:
... print(key, value)
...
Python exception:
ValueError: not enough values to unpack (expected 2, got 1)
A ValueError indicates that a function or an operation
received an argument of the right type, but an inappropriate value.
Execution stopped on line 1 of file '<friendly-console:2>'.
-->1: for key, value in d:
d: {'a': 1, 'b': 2}
==
André Roberge
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/UIDNB2EZQYVUBHNMDIHJ7CZYKMRM6UJV/
Code of Conduct: http://python.org/psf/codeofconduct/