Re: [Tutor] _next

2006-05-31 Thread Roel Schroeven
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

Re: [Tutor] _next

2006-05-30 Thread Dave Kuhlman
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 >

Re: [Tutor] _next

2006-05-25 Thread Roel Schroeven
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

Re: [Tutor] _next

2006-05-25 Thread Roel Schroeven
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

Re: [Tutor] _next

2006-05-24 Thread Kent Johnson
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

[Tutor] _next

2006-05-24 Thread Christopher Spears
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: