Re: Unpacking Tuples
Joel Davis wrote: I hate to post such a simple Q and A here, but I seriously can't find it anywhere. Python (unsure of starting with which version) enables the remainder of the tuple to be placed in a "catch-all", for example: myTuple = (1,2,3,4) varOne, varTwo, *remaindingTuple = myTuple. where the values left unpacked get thrown into a tuple referenced to by "remaindingTuple" I included the asterix because it seems like I remember that being the operator that specifying the tuple's dumping ground. Which brings me to my two questions: 1) what's the syntax for this operation 2) what version does it start with? 1) Syntax is just as you have it. (Not including the period you have at the end.) 2) Python 3.0 Gary Herron -- http://mail.python.org/mailman/listinfo/python-list
Re: Unpacking Tuples
On Mon, Nov 30, 2009 at 12:17 AM, Joel Davis wrote: > I hate to post such a simple Q and A here, but I seriously can't find > it anywhere. Python (unsure of starting with which version) enables > the remainder of the tuple to be placed in a "catch-all", for example: > > >>> myTuple = (1,2,3,4) >>> varOne, varTwo, *remaindingTuple = myTuple. > > where the values left unpacked get thrown into a tuple referenced to > by "remaindingTuple" I included the asterix because it seems like I > remember that being the operator that specifying the tuple's dumping > ground. Which brings me to my two questions: > 1) what's the syntax for this operation Exactly as you showed above (well, minus the period obviously). 2) what version does it start with? Python 3.0 It might be backported into 2.7 when it gets released: http://bugs.python.org/issue2340 Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
Unpacking Tuples
I hate to post such a simple Q and A here, but I seriously can't find it anywhere. Python (unsure of starting with which version) enables the remainder of the tuple to be placed in a "catch-all", for example: >> myTuple = (1,2,3,4) >> varOne, varTwo, *remaindingTuple = myTuple. where the values left unpacked get thrown into a tuple referenced to by "remaindingTuple" I included the asterix because it seems like I remember that being the operator that specifying the tuple's dumping ground. Which brings me to my two questions: 1) what's the syntax for this operation 2) what version does it start with? -- http://mail.python.org/mailman/listinfo/python-list