[Python-Dev] re: Sets BOF / for in dict

Ka-Ping Yee ping@lfw.org
Mon, 5 Feb 2001 11:15:18 -0800 (PST)


On Mon, 5 Feb 2001, M.-A. Lemburg wrote:
> Two things: 
> 
> 1. the proposed syntax key:value does away with the
>    easy to parse Python block statement syntax

Oh, come on.  Slices and dictionary literals use colons too,
and there's nothing wrong with that.  Blocks are introduced
by a colon at the *end* of a line.

> 2. why can't we use the old 'for x,y,z in something:' syntax
>    and instead add iterators to the objects in question ?
> 
>    for key, value in object.iterator():
>       ...

Because there's no good answer for "what does iterator() return?"
in this design.  (Trust me; i did think this through carefully.)
Try it.  How would you implement the iterator() method?

The PEP *is* suggesting that we add iterators to the objects --
just not that we explicitly call them.  In the 'for' loop you've
written, iterator() returns a sequence, not an iterator.


-- ?!ng