Dave Kuhlman schreef:
> Roel Schroeven fastmail.fm> writes:
> Kent Johnson alerted me to this discussion.
>
> And, thanks, Roel, for the comments and improvements on my example.
>
> I agree that my example class being discussed is confused. I've reworked the
> example, taking hints from this t
Roel Schroeven fastmail.fm> writes:
[good suggestions snipped]
>
> The _next() method is a generator function as I described above, which
> creates an iterator object when called.
> The __iter__() method just calls that generator function and returns the
> result to its caller.
>
> HTH
>
Christopher Spears schreef:
> How does this script work?
>
> #!/usr/bin/python
>
> class IteratorExample:
> def __init__(self, s):
> self.s = s
> self.next = self._next().next
> self.exhausted = 0
> def _next(self):
> if not self.exhausted:
> fl
Christopher Spears schreef:
> How does this script work?
>
> #!/usr/bin/python
>
> class IteratorExample:
> def __init__(self, s):
> self.s = s
> self.next = self._next().next
> self.exhausted = 0
> def _next(self):
> if not self.exhausted:
> fl
Christopher Spears wrote:
> How does this script work?
>
> #!/usr/bin/python
>
> class IteratorExample:
> def __init__(self, s):
> self.s = s
> self.next = self._next().next
> self.exhausted = 0
> def _next(self):
> if not self.exhausted:
> flag
How does this script work?
#!/usr/bin/python
class IteratorExample:
def __init__(self, s):
self.s = s
self.next = self._next().next
self.exhausted = 0
def _next(self):
if not self.exhausted:
flag = 0
for x in self.s: