Message307896
The error message is correct, but I'm sorry it's confusing.
Here's an equivalent error:
a, b = 3
You'll get the error "TypeError: 'int' object is not iterable". That's because Python sees 2 items to the left of the assignment, so it needs to extract 2 items from the right side. To get 2 values from the right side, it iterates over the right side. In this case, 3 cannot be iterated over, thus the error message.
Now consider:
a, b = 3, 4
Again, to get 2 items from the right side, Python iterates over it. In this case the thing on the right side is a 2 element tuple. It's a little confusing that it's a tuple because it doesn't have parentheses, but the comma between 3 and 4 makes it a tuple. In this case, Python can iterate over the tuple, and the tuple has exactly 2 elements, so the assignment to a and b succeeds with a = 3 and b = 4.
I hope that clears it up. |
|
Date |
User |
Action |
Args |
2017-12-09 12:40:53 | eric.smith | set | recipients:
+ eric.smith, Camion |
2017-12-09 12:40:53 | eric.smith | set | messageid: <1512823253.03.0.213398074469.issue32259@psf.upfronthosting.co.za> |
2017-12-09 12:40:52 | eric.smith | link | issue32259 messages |
2017-12-09 12:40:52 | eric.smith | create | |
|