Syntactic sugar for assignment statements: one value to multiple targets?
katriel at katriel.co.uk
Wed Aug 3 10:36:19 CEST 2011
On Wed, Aug 3, 2011 at 9:25 AM, Steven D'Aprano <
steve+comp.lang.python at pearwood.info> wrote:
> 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)]
I think this is good code -- if you want five different dicts, then you
should call dict five times. Otherwise Python will magically call your
expression more than once, which isn't very nice. And what if your datatype
constructor has side-effects?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list