Timeline for How do I merge two dictionaries in a single expression in Python?
Current License: CC BY-SA 4.0
11 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
May 29, 2022 at 18:16 | comment | added | run_the_race |
@RaymondHettinger We all know you designed ChainMap in the most reasonable way, thank you for it!
|
|
Dec 11, 2020 at 6:43 | history | edited | Raymond Hettinger | CC BY-SA 4.0 |
Update for 3.9
|
Apr 22, 2020 at 12:46 | history | edited | Ravindra S | CC BY-SA 4.0 |
Correction in the code. You have to explicity convert the returned ChainMap to dict to be able to iterate over it like dict.
|
Nov 20, 2019 at 17:03 | history | edited | Neuron | CC BY-SA 4.0 |
edited body
|
Sep 9, 2019 at 15:09 | history | edited | Raymond Hettinger | CC BY-SA 4.0 |
Add Python 3.5 update
|
Jul 15, 2019 at 16:30 | comment | added | wjandrea |
@Prerit You could cast to dict to avoid that, i.e.: dict(ChainMap({}, y, x))
|
|
Feb 15, 2017 at 15:15 | comment | added | Slayer | @Raymond Hettinger I agree, just added a caution. Most people may not know about it. :D | |
Feb 15, 2017 at 7:24 | comment | added | Raymond Hettinger | @Prerit What else would you expect it to do? That's the normal way chained namespaces work. Consider how $PATH works in bash. Deleting an executable on the path doesn't preclude another executable with the same name further upstream. | |
Feb 14, 2017 at 5:14 | comment | added | Slayer |
But one should be cautious while using ChainMap there's a catch that if you have duplicate keys the values from first mapping get used and when you call a del on say a ChainMap c will delete the first mapping of that key.
|
|
Sep 27, 2014 at 8:12 | history | edited | Raymond Hettinger | CC BY-SA 3.0 |
Make *z* independent of *x* and *y*.
|
Apr 28, 2013 at 3:15 | history | answered | Raymond Hettinger | CC BY-SA 3.0 |