brennerm / PyTricks

Collection of less popular features and tricks for the Python programming language
MIT License
3.07k stars 502 forks source link

Add example of ovelapping (key:value) on dicts for Python3 #33

Closed raulcd closed 9 years ago

raulcd commented 9 years ago

In Python 3 if dicts have overlapping (key: value) pairs you can have them with the dict_items_view and binary operator:

for item in dctA.items() & dctB.items():
    print(item)
brennerm commented 9 years ago

already shown in loopoverlappingdicts.py ;)

raulcd commented 9 years ago

No, what is showing currently is if the keys are the same but not if both key and value are the same ;)