unpacking with default values

McA andreas.mock at web.de
Thu Jul 17 13:27:38 EDT 2008


On 17 Jul., 18:33, Gary Herron <gher... at islandtraining.com> wrote:
>
> In Python 2.x, you can't do that directly, but you should be able to
> create a function that lengthens or shortens an input tuple of arguments
> to the correct length so you can do:
>
>   a,c,b = fix(1,2)
>   d,e,f = fix(1,2,3,4)
>
> However, the function won't know the length of the left hand side
> sequence, so it will have to be passed in as an extra parameter or hard
> coded.

Hi Gary,

thank you for the answer.
Do you know the "protocol" used by python while unpacking?
Is it a direct assingnment? Or iterating?

Best regards
Andreas Mock



More information about the Python-list mailing list