George Sakkis wrote: > far too often I use the idiom dict(zip(keys,values)), or > the same with izip. How does letting dict take two positional > arguments sound ? I think the dict constructor is already a bit too complicated, and would prefer that it be a separate classmethod, such as dict.zip(keys, values=itertools.repeat(None)) The default argument on values should finish the replacement of dict.fromkeys functionality that sets and defaultdicts began. > At least as efficient as the current alternatives. I think it has to do better (at least by eliminating the temporary zip object) to be worthwhile; the do-it-yourself alternative is pretty short. >>> # from itertools import izip as zip >>> def dictz(keys, values): return dict(zip(keys,values)) -jJ
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4