[Python-Dev] iterators

Fredrik Lundh fredrik@pythonware.com
Mon, 21 Aug 2000 12:43:47 +0200


mal wrote:
> How about a third variant:
> 
> #3:
> __iter = <object>.iterator()
> while __iter:
>    <variable> = __iter.next()
>    <block>

how does that one terminate?

maybe you meant something like:

    __iter = <object>.iterator()
    while __iter:
        <variable> = __iter.next()
        if <variable> is <sentinel>:
            break
        <block>

(where <sentinel> could be __iter itself...)

</F>