Writing to a certain line?

Fredrik Lundh fredrik at pythonware.com
Wed Jun 7 14:17:22 EDT 2006


Christophe wrote:

> Use /dev/zero as source and /dev/null as destination :D

have you tried looping over an endless null-byte stream?

on a random Linux server, this statement

 >>> for line in open("/dev/zero"):
...     print len(line)
...

terminates without printing anything after about three seconds, which is 
a bit odd.  in contrast,

 >>> f = open("/dev/zero")
 >>> len(f.readline())

raises a MemoryError exception after about 10 seconds.  hmm.  looks like 
a bug in the file iterator, really...

</F>




More information about the Python-list mailing list