Closed zhangfelix closed 2 years ago
Using dictionary comprehension instead of map and zip can simplify the snippet, while enhancing the readability of the code, making it easier to understand.
map
zip
Before:
def map_dictionary(itr, fn): return dict(zip(itr, map(fn, itr)))
After:
def map_dictionary(itr, fn): return {x:fn(x) for x in itr}
Using dictionary comprehension instead of
map
andzip
can simplify the snippet, while enhancing the readability of the code, making it easier to understand.Before:
After: