A RetroSearch Logo

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

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2002-November/029900.html below:

[Python-Dev] metaclass insanity

[Python-Dev] metaclass insanity [Python-Dev] metaclass insanityJust van Rossum just@letterror.com
Tue, 5 Nov 2002 09:48:03 +0100
Just van Rossum wrote:

> class Outer:
>     [snip snip]
>     def __iter__(self):
>         while not self.isAtEnd():
>             result = self.outer.currentState()
>             self.outer.advanceState()
>             yield result

PS, getting more off-topic, I'm somewhat surprised that the above is more
compact and readable than the obvious generator-less equivalent:

class Outer:
    [snip snip]
    def __iter__(self):
        return self
    def next(self):
        if self.isAtEnd():
            raise StopIteration
        else:
            result = self.outer.currentState()
            self.outer.advanceState()
            return result

Just



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