PEP 234 little bug? 
Author Message
 PEP 234 little bug?

Just read through some of the already implemented PEPs.

PEP 234 (iterators) states:

Quote:
>    - It has been proposed that a file object should be its own
>      iterator, with a next() method returning the next line.  This
>      has certain advantages, and makes it even clearer that this
>      iterator is destructive.  The disadvantage is that this would
>      make it even more painful to implement the "sticky
>      StopIteration" feature proposed in the previous bullet.

>      Resolution: this has been implemented.

I can't see a next() in a file object. Shouldn't it be
"Resolution: this has not been implemented." ?

Yours,

:M:



Thu, 19 Aug 2004 07:45:44 GMT  
 PEP 234 little bug?

Quote:

> Just read through some of the already implemented PEPs.

> PEP 234 (iterators) states:

> >    - It has been proposed that a file object should be its own
> >      iterator, with a next() method returning the next line.  This
> >      has certain advantages, and makes it even clearer that this
> >      iterator is destructive.  The disadvantage is that this would
> >      make it even more painful to implement the "sticky
> >      StopIteration" feature proposed in the previous bullet.

> >      Resolution: this has been implemented.

> I can't see a next() in a file object. Shouldn't it be
> "Resolution: this has not been implemented." ?

Hm, I don't think so. I think it does not say that the *file*
object should have a next() method... rather, it says that
it's its own iterator, and the iterator has the next()
method. Maybe the wording could have been a bit more careful,
but essentially it's true what is says. And iterating over
files has indeed been implemented in 2.2.

--
Hans (base64.decodestring('d3VybXlAZWFydGhsaW5rLm5ldA=='))
# decode for email address ;-)
The Pythonic Quarter:: http://www.awaretek.com/nowak/



Thu, 19 Aug 2004 09:42:25 GMT  
 PEP 234 little bug?

Quote:
> Just read through some of the already implemented PEPs.
> PEP 234 (iterators) states:
>>      Resolution: this has been implemented.
> I can't see a next() in a file object. Shouldn't it be
> "Resolution: this has not been implemented." ?

No, but you can find a `__iter__' method, and in places where an
iterator is expected that function is called, and low and behold
the resulting object of that __iter__ call does have a next method.

So all is well after all:)

--
groetjes, carel



Thu, 19 Aug 2004 10:07:51 GMT  
 PEP 234 little bug?
[...]

Quote:
> Hm, I don't think so. I think it does not say that the *file*
> object should have a next() method... rather, it says that
> it's its own iterator, and the iterator has the next()
> method. Maybe the wording could have been a bit more careful,
> but essentially it's true what is says. And iterating over
> files has indeed been implemented in 2.2.

Yes, I was aware of that - I just thought the line
"is implemented" would mean the inclusion of the
(proposed) fileobject.next() method [which as a matter
of fact is _not_ implemented], not the iterator
itself.

Thanks for your response.

Later,

Mickey.



Thu, 19 Aug 2004 09:30:12 GMT  
 PEP 234 little bug?


Quote:

> > Just read through some of the already implemented PEPs.

> > PEP 234 (iterators) states:

> > >    - It has been proposed that a file object should be its own
> > >      iterator, with a next() method returning the next line.  This
> > >      has certain advantages, and makes it even clearer that this
> > >      iterator is destructive.  The disadvantage is that this would
> > >      make it even more painful to implement the "sticky
> > >      StopIteration" feature proposed in the previous bullet.

> > >      Resolution: this has been implemented.

> > I can't see a next() in a file object. Shouldn't it be
> > "Resolution: this has not been implemented." ?

> Hm, I don't think so. I think it does not say that the *file*
> object should have a next() method... rather, it says that
> it's its own iterator, and the iterator has the next()
> method. Maybe the wording could have been a bit more careful,
> but essentially it's true what is says. And iterating over
> files has indeed been implemented in 2.2.

Just yesterday I've filed a bug about the current behavior that is
caused by the fact that the file object is *not* its own iterator:

http://sourceforge.net/tracker/?func=detail&aid=524804&group_id=5470&...
=105470

Just



Thu, 19 Aug 2004 16:54:20 GMT  
 PEP 234 little bug?

Quote:




> > > Just read through some of the already implemented PEPs.

> > > PEP 234 (iterators) states:

> > > >    - It has been proposed that a file object should be its own
> > > >      iterator, with a next() method returning the next line.  This
> > > >      has certain advantages, and makes it even clearer that this
> > > >      iterator is destructive.  The disadvantage is that this would
> > > >      make it even more painful to implement the "sticky
> > > >      StopIteration" feature proposed in the previous bullet.

> > > >      Resolution: this has been implemented.

> > > I can't see a next() in a file object. Shouldn't it be
> > > "Resolution: this has not been implemented." ?

> > Hm, I don't think so. I think it does not say that the *file*
> > object should have a next() method... rather, it says that
> > it's its own iterator, and the iterator has the next()
> > method. Maybe the wording could have been a bit more careful,
> > but essentially it's true what is says. And iterating over
> > files has indeed been implemented in 2.2.

> Just yesterday I've filed a bug about the current behavior that is
> caused by the fact that the file object is *not* its own iterator:

Should it be? This may be a dumb question, but are there important
reasons to do this, besides conformance with the PEP? I mean, the
current situation does do the job; "for line in file" works. What
would be the additional benefit of making a file its own
iterator?

--
Hans (base64.decodestring('d3VybXlAZWFydGhsaW5rLm5ldA=='))
# decode for email address ;-)
The Pythonic Quarter:: http://www.awaretek.com/nowak/



Fri, 20 Aug 2004 06:21:40 GMT  
 PEP 234 little bug?


Quote:

>Should it be? This may be a dumb question, but are there important
>reasons to do this, besides conformance with the PEP? I mean, the
>current situation does do the job; "for line in file" works. What
>would be the additional benefit of making a file its own
>iterator?

The following code would work correctly:

for line in file:
    if line == 'foo':
        break
for line in file:
    pass
--

Hugs and backrubs -- I break Rule 6                 http://www.*-*-*.com/
Androgynous poly {*filter*} vanilla {*filter*} het Pythonista

"How come we choose from just two people for President but more than 50
for Miss America?"  --AEN



Fri, 20 Aug 2004 12:34:12 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. PEP 234: Iterators

2. PEP 234: Iterators

3. PEP 234: Iterators

4. PEP 234: Iterators (fwd)

5. Discussion about PEP 234: iterators

6. PEP 234: Iterators (fwd)

7. Jun for Java 234

8. API routine CryptEncrypt() returns error 234

9. Opening up PEPS a little more.

10. 1 little, 2 little, 3 little endians...

11. PEP 6: Patch and Bug Fix Releases

12. PEP 6: Patch and Bug Fix Releases

 

 
Powered by phpBB® Forum Software