[Python-ideas] Unpack of sequences

Guido van Rossum guido at python.org
Thu Aug 30 16:50:45 CEST 2012


On Wed, Aug 29, 2012 at 11:57 PM, Serhiy Storchaka <storchaka at gmail.com> wrote:
> On 29.08.12 21:20, Steven D'Aprano wrote:
>>
>> But once you have multiple
>> targets,
>> it gets ugly soon, e.g. the typical enumeration (anti-)pattern:
>>
>> RED, YELLOW, BLUE, GREEN = 'RED', 'YELLOW', 'BLUE', 'GREN'
>
>
>   for n in 'RED', 'YELLOW', 'BLUE', 'GREN':
>       globals()[n] = n

Please, please, please. I much prefer to repeat myself than to use
such an ugly hack.

-- 
--Guido van Rossum (python.org/~guido)



More information about the Python-ideas mailing list