Syntactic sugar for assignment statements: one value to multiple targets?

Steven D'Aprano steve+comp.lang.python at pearwood.info
Wed Aug 3 10:25:51 CEST 2011


gc wrote:

> Target lists using comma separation are great, but they don't work
> very well for this task. What I want is something like
> 
> a,b,c,d,e = *dict()


a, b, c, d, e = [dict() for i in range(5)]

Unfortunately there is no way of doing so without counting the assignment
targets. While slightly ugly, it doesn't seem ugly enough to justify the
extra complexity of special syntax for such a special case.


-- 
Steven




More information about the Python-list mailing list