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
participants (1)
-
Jim Jewett