Created
May 24, 2015 20:40
-
-
Save curzona/17a7e4287ec04226f3ed to your computer and use it in GitHub Desktop.
Add operator for Dictionaries
This file contains hidden or 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
| from pprint import pprint | |
| a = _Dict({'a':'1'}) | |
| b = _Dict({'b':'2'}) | |
| pprint(a + b) |
This file contains hidden or 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
| class _Dict(dict): | |
| def __add__(a, b): | |
| n = dict() | |
| n.update(a) | |
| n.update(b) | |
| return n |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment