[BangPypers] Unpacking Tuple

Saju M sajuptpm at gmail.com
Sat Oct 6 12:09:46 CEST 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 BangPypers mailing list