[New-bugs-announce] [issue42723] Unclear why dict unpacking cannot be used in dict comprehension
Luke Davis
report at bugs.python.org
Wed Dec 23 06:21:19 EST 2020
New submission from Luke Davis <lukedavis at live.com>:
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():
dict = { **dict, **sub_dict }
Am I wrong in thinking the first and second block of code should do the same thing behind the scenes?
----------
messages: 383641
nosy: PartlyFluked
priority: normal
severity: normal
status: open
title: Unclear why dict unpacking cannot be used in dict comprehension
type: enhancement
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42723>
_______________________________________
More information about the New-bugs-announce
mailing list