Skip to content

Instantly share code, notes, and snippets.

@emsi
Last active June 18, 2019 10:16
Show Gist options
  • Save emsi/750a9cb0ef75044cce9afc5003c695d2 to your computer and use it in GitHub Desktop.
Save emsi/750a9cb0ef75044cce9afc5003c695d2 to your computer and use it in GitHub Desktop.
Chainable python dict update and key remove
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