Thought on PEP 204 and 276

Steve Horne steve at lurking.demon.co.uk
Tue May 28 09:45:30 EDT 2002


On Mon, 27 May 2002 21:33:47 +0200, holger krekel
<pyth at devel.trillke.net> wrote:

>       for i,item in enumerate(somelist):
>            # use item
>            somelist[i]=newvalue

Could enumerate(dictionary) be used to extract key, value pairs from a
dictionary?

I realise this duplicates the items() method, but it has the advantage
of creating consistency between sequence and mapping types.

Also, why wasn't an items() method simply added to sequence types,
treating them as mapping types with an integer key?

-- 
Steve Horne
steve at lurking.demon.co.uk



More information about the Python-list mailing list