On Fri, 2009-05-22 at 10:54 -0700, Jan wrote:
> This produces an error because by definition of for-loops
> it is executed the same way as:
>
> temp_iterator = iter(y) # temp_iterator is y
> while True:
> try:
> print(next(temp_iterator)) # temp_iterator does not support
> __next__()
>
On Fri, 2009-05-22 at 10:54 -0700, Jan wrote:
> On May 22, 9:46 am, "J. Cliff Dyer" wrote:
>
> > You don't need a reset method. There is no hard and fast rule that
> > __iter__ must return the object itself. It just needs to return an
> > iterator.
>
> I disagree.
> If ITRATOR is a true ite
On May 22, 9:46 am, "J. Cliff Dyer" wrote:
> You don't need a reset method. There is no hard and fast rule that
> __iter__ must return the object itself. It just needs to return an
> iterator.
I disagree.
If ITRATOR is a true iterator, ITRATOR.__iter__() must return
ITERATOR.
If ITERABLE is
On Wed, 2009-05-20 at 11:35 -0700, Jan wrote:
> Wouldn't it be easy for Python to implement generating functions so
> that the iterators they return are equipped with a __reset__() method?
>
> Here is the context of this question.
>
> Python documentation defines a "iterator" as an object ITERAT
norseman wrote:
Terry Reedy wrote:
I will clarify by starting over with current definitions.
Ob is an iterator iff next(ob) either returns an object or raises
StopIteration and continues to raise StopIteration on subsequent calls.
Ob is an iterable iff iter(ob) raturns an iterator.
It is in
Terry Reedy wrote:
I will clarify by starting over with current definitions.
Ob is an iterator iff next(ob) either returns an object or raises
StopIteration and continues to raise StopIteration on subsequent calls.
Ob is an iterable iff iter(ob) raturns an iterator.
It is intentional that th
I will clarify by starting over with current definitions.
Ob is an iterator iff next(ob) either returns an object or raises
StopIteration and continues to raise StopIteration on subsequent calls.
Ob is an iterable iff iter(ob) raturns an iterator.
It is intentional that the protocol definitio
Terry Reedy wrote:
Jan wrote:
Wouldn't it be easy for Python to implement generating functions so
that the iterators they return are equipped with a __reset__() method?
No. Such a method would have to poke around in the internals of the
__next__ function in implementation specific ways. The
Steven D'Aprano wrote:
> On Wed, 20 May 2009 11:35:47 -0700, Jan wrote:
>
>> Wouldn't it be easy for Python to implement generating functions so that
>> the iterators they return are equipped with a __reset__() method?
>
> No.
>
> def gen():
> for name in os.listdir('.'):
> yield o
On Wed, 20 May 2009 11:35:47 -0700, Jan wrote:
> Wouldn't it be easy for Python to implement generating functions so that
> the iterators they return are equipped with a __reset__() method?
No.
def gen():
for name in os.listdir('.'):
yield open(name).read()
os.remove(name)
Jan wrote:
Wouldn't it be easy for Python to implement generating functions so
that the iterators they return are equipped with a __reset__() method?
No. Such a method would have to poke around in the internals of the
__next__ function in implementation specific ways. The values used to
ini
Jan wrote:
Wouldn't it be easy for Python to implement generating functions so
that the iterators they return are equipped with a __reset__() method?
Use ``send``:
http://docs.python.org/whatsnew/2.5.html#pep-342-new-generator-features
Remember, there may be no underlying sequence object for
a
On May 20, 2:48 pm, Jan wrote:
Iterators can also be produced by iter(ITERABLE) which
could mnufacture them with a __reset__.
Jan
--
http://mail.python.org/mailman/listinfo/python-list
On May 20, 2:35 pm, Jan wrote:
OOPS, I have pressed some keys and the message went out before It was
finished.
Here is the last fragment:
So, one can define iterators by defining a class whose objects have
methods
__iter__ and __next__ -- with this approach it is easy to add some
__reset__
metho
Wouldn't it be easy for Python to implement generating functions so
that the iterators they return are equipped with a __reset__() method?
Here is the context of this question.
Python documentation defines a "iterator" as an object ITERATOR
having methods __next__() and __iter__() such that the
15 matches
Mail list logo