[issue42723] Unclear why dict unpacking cannot be used in dict comprehension

2020-12-23 Thread Steven D'Aprano
Steven D'Aprano added the comment: They don't do the same thing. The dict comprehension requires a single key:value pair per loop. It accumulates values into a single dict. Try this: d = {} for key, value in items: print(id(d)) d[key] = value The ID doesn't change

[issue42723] Unclear why dict unpacking cannot be used in dict comprehension

2020-12-23 Thread Luke Davis
New submission from Luke Davis : Why am I unable to do: dict = { **sub_dict for sub_dict in super_dict.values() } which throws: "dict unpacking cannot be used in dict comprehension" Whereas the equivalent code below doesn't throw any errors?: dict = {} for sub_dict in super_dict.values():