[Python-Dev] Any grammar experts?

Serhiy Storchaka storchaka at gmail.com
Mon Jan 26 21:50:08 CET 2015


On 26.01.15 00:59, Guido van Rossum wrote:
> Interestingly, the non-dict versions can all be written today using a
> double-nested comprehension, e.g. {**x for x in it} can be written as:
>
>      {x for x in xs for xs in it}

      {x for xs in it for x in xs}

> But it's not so straightforward for dict comprehensions -- you'd have to
> switch to calling dict():
>
>      dict(x for x in xs for xs in it)

      {k: v for xs in it for k, v in xs.items()}

So actually this is just a syntax sugar.




More information about the Python-Dev mailing list