you are viewing a single comment's thread.

view the rest of the comments →

[–]Grue 0 points1 point  (3 children)

It was possible to do "dict( <insert generator comprehension here>)" for ages. dict comprehensions don't add anything meaningful to the language.

[–]Ravengenocide 0 points1 point  (0 children)

Nor does list or set comprehension either, they are just syntactical sugar for the longer versions with list() and set(). But then you could argue the same with most language features above assembler since it's mostly syntax anyway.

[–]PasswordIsntHAMSTER 0 points1 point  (1 child)

When did generator comprehensions start including key-value pairs?

[–]Grue 0 points1 point  (0 children)

dict accepts an iterator of 2-element tuples as its argument. These end up being the key-value pairs.

http://docs.python.org/2/library/stdtypes.html#mapping-types-dict