Timeline for How do I merge two dictionaries in a single expression in Python?
Current License: CC BY-SA 2.5
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 15, 2022 at 9:15 | comment | added | Alexander Oh | @WilliamMartens it wasn't a joke. But let's face it, if you optimize for single line expressions,you are optimizing for the wrong thing. | |
Jul 15, 2022 at 4:08 | comment | added | William Martens |
@AlexanderOh I am not sure whenever this is a joke or not; I see this as a perfectly (valid) answ! (at least in terms of it works) but Of course; yeah; the second comment sets a precedent! either way; it is Indeed pythonic!
|
|
Feb 24, 2020 at 12:43 | comment | added | towr |
Well, if people insist on making it a oneliner, you can always do (lambda z: z.update(y) or z)(x.copy()) :P
|
|
Oct 19, 2017 at 13:07 | comment | added | eric |
Put it this way: if you need to put two lines of comments explaining your one line of code to the people you hand your code off to...have you really done it in one line? :) I fully agree Python is not good for this: there should be a much easier way. While this answer is more pythonic, is it really all that explicit or clear? Update is not one of the "core" functions that people tend to use a lot.
|
|
Oct 3, 2014 at 2:55 | review | Suggested edits | |||
Oct 3, 2014 at 3:14 | |||||
Mar 21, 2013 at 13:15 | comment | added | Alexander Oh | To clarify why this doesn't meet the critera provided by the question: it's not a single expression and it doesn't return z. | |
Sep 2, 2008 at 13:00 | history | answered | Matthew Schinckel | CC BY-SA 2.5 |