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/2004-January/041632.html below:

[Python-Dev] Toowtdi: Datatype conversions

[Python-Dev] Toowtdi: Datatype conversionsRobert Brewer fumanchu at amor.org
Sat Jan 3 16:37:38 EST 2004
Raymond Hettinger wrote:
> Choosing between:
> 
>     list(d)  or   d.keys()
> 
> Which is the one obvious way of turning a dictionary into a list?  
> IMO, list(d) is it.

Except that, "turning a dictionary into a list" as an English phrase is
indeterminate--do you want the keys or the values or both? list(d)
happens to choose the keys, but that doesn't make it the "one obvious
way". If I were being introduced to list() for the first time, I would
probably expect/desire it to be lossless, producing something like
d.items() instead.

> So, one question is whether set() and frozenset() should grow an
> analogue to the keys() method:
> >>> set('banana').elements()
> ['a', 'b', 'n']

I don't think so, for the reason that .keys() is effectively a
disambiguator as I just described. With sets, there is no mapping, and
therefore no ambiguity.


Robert Brewer
MIS
Amor Ministries
fumanchu at amor.org

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