[Python-ideas] Syntax for key-value iteration over mappings

Steven D'Aprano steve at pearwood.info
Mon Jul 27 04:36:48 CEST 2015


On Mon, Jul 27, 2015 at 12:12:09PM +1000, Steven D'Aprano wrote:
[...]
> It's one more special case syntax for beginners to learn. And it really 
> is a special case: there's nothing about "for k:v in iterable" that 
> tells you that iterable must have an items() method. You have to 
> memorise that fact.

I forgot to say, "or whatever implementation you choose for this 
syntax". It doesn't necessarily have to be calling the items() method, 
although the proof of concept given does that. The principle applies 
either way.


-- 
Steve


More information about the Python-ideas mailing list