[Python-3000] suggestion: structured assignment
allyourcode at gmail.com
allyourcode at gmail.com
Thu May 29 06:34:14 CEST 2008
Well, I'm sorry for bothering his majesty with such a stupid idea. At
least one other person didn't know about it either...
On 5/28/08, Mike Klaas <mike.klaas at gmail.com> wrote:
>
> On 28-May-08, at 6:23 PM, Daniel Wong wrote:
>
>> Currently, I must do the following instead:
>>
>> for n, pair in enumerate(list_of_pairs):
>> a, b = pair
>> ...
>>
>> <>
>> Thoughts?
>
> I find it hard to believe that you have even attempted this, which has
> been valid in python for ages:
>
> >>> for x, (a, b) in enumerate([(1,2), (3,4), (5,6)]):
> print x, a, b
>
> 0 1 2
> 1 3 4
> 2 5 6
>
> -Mike
>
More information about the Python-3000
mailing list