Unpaking Tuple

sajuptpm sajuptpm at gmail.com
Sat Oct 6 06:09:30 EDT 2012


Hi,

I am using python 2.6.

I need a way to make following code working without any ValueError .
>>> a, b, c, d = (1,2,3,4)
>>> a, b, c, d = (1,2,3).

Note: Number of values in the tuple will change dynamically.


I know in python 3, you can do `a, b, c, *d = (1, 2, 3)` and then d will contain any elements that didn't fit into a,b,c.

Regards,
Saju



More information about the Python-list mailing list