Unpacking and Conditional Expressions
Unpacking tuples and conditional expressions in Python.
The other day whilst working on a web crawler at work called spyda I came across an interesting behavior in Python. Here it goes: >>> xs = [(1, 2), (3, 4)] >>> a, b = xs if xs else None, None >>> a (1, 2) >>> b Notice that a becomes the first tuple in the list and b becomes None? This kinda got me stumped at first until I realized what was happening with the Python parser. [Read More]