A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2007-February/070867.html below:

[Python-Dev] dict(keys, values)

[Python-Dev] dict(keys, values) [Python-Dev] dict(keys, values)Jim Jewett jimjjewett at gmail.com
Thu Feb 1 21:16:06 CET 2007
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
More information about the Python-Dev mailing list

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