[issue11163] iter() documentation code doesn't work

2011-06-25 Thread Michael Grazebrook

Michael Grazebrook  added the comment:

Thank you.

On 25/06/2011 13:38, Raymond Hettinger wrote:
> Changes by Raymond Hettinger:
>
>
> --
> resolution:  ->  fixed
> status: open ->  closed
>
> ___
> Python tracker
> <http://bugs.python.org/issue11163>
> ___
>
>
> -
> No virus found in this message.
> Checked by AVG - www.avg.com
> Version: 10.0.1388 / Virus Database: 1513/3725 - Release Date: 06/25/11
>
>
>

--

___
Python tracker 
<http://bugs.python.org/issue11163>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11163] iter() documentation code doesn't work

2011-02-09 Thread Michael Grazebrook

New submission from Michael Grazebrook :

This code fragment from the documentation of iter() doesn't work as intended. 
Change "STOP" to "STOP\n". Maybe also check for EOF as it hangs.

with open("mydata.txt") as fp:
for line in iter(fp.readline, "STOP"):
process_line(line)

Or maybe this makes a better example because it's clearer wha'ts going on:

square_generator = (i * i for i in range(10))
for n in iter( square_generator.next, 144):
print n

--
assignee: docs@python
components: Documentation
messages: 128238
nosy: docs@python, mgrazebrook
priority: normal
severity: normal
status: open
title: iter() documentation code doesn't work
type: behavior
versions: Python 2.6

___
Python tracker 
<http://bugs.python.org/issue11163>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com