Unpacking Tuples

Gary Herron gherron at islandtraining.com
Mon Nov 30 03:32:38 EST 2009


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





More information about the Python-list mailing list