A RetroSearch Logo

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

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2002-April/023524.html below:

[Python-Dev] Re: PEP 279 revisited

[Python-Dev] Re: PEP 279 revisitedGuido van Rossum guido@python.org
Wed, 24 Apr 2002 08:47:25 -0400
> If you consider lists to be a special dictionary 
> with implicit keys we can define 'items' to 
> generate (key,value) pairs for a collection so that 
> 
>     for key,value in items(collection):
>         collection[key]==value 
> 
> holds no matter if collection is a list or a dictionary,

This has been proposed and rejected before.  We've made the decision
that "iter(dict)" iterates over the keys while "iter(list)" iterates
over the values, and anything that tries to unify the two types
(really categories of types: sequences and mappings) is bound to fail.

> btw, i usually don't need an extra numbering for my dictionaries.
> If really in need i would write
> 
>     list = dict.items()
>     for index,item in items(list): ...
> 
> using the above semantics.

That's another argument why what this function (whatever it's called)
does on dicts is irrelevant: you wouldn't want to use it on a dict
anyway.  It's something for sequences and iterators.

--Guido van Rossum (home page: http://www.python.org/~guido/)




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