I have found something like this in a code I'm working with:
[], my_variable = my_function(a, b)
where the output of my_function goes like:
return some_dict, some_list
This seems to work - unit tests of a system don't fail, but when I try this at the python console (assigning dictionary to "[]") it raises:
ValueError: too many values to unpack
Have you seen something like this? How does assigning a dictionary (or something else) to empty list constant "[]" work?
Or it doesn't and tests are missing something...
It's because in your test file, the return value
is {}
.
>>> [] = {}
>>> [] = {1:2}
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: too many values to unpack
>>> [] = []
>>> [] = [1,2]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: too many values to unpack
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With