Last active
June 18, 2019 10:16
-
-
Save emsi/750a9cb0ef75044cce9afc5003c695d2 to your computer and use it in GitHub Desktop.
Chainable python dict update and key remove
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d1={1:1, 2:2, 3:3} | |
d2={3:4, 5:6, 7:8} | |
def update(d1, d2): | |
return dict(d1, **d2) | |
def update2(d1, d2): | |
return (lambda d: d.update(d2) or d)(d1) | |
def remove(d, k): | |
return d.__delitem__(k) or d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment