[Python-ideas] os.listdir iteration support

Giampaolo Rodola' gnewsg at gmail.com
Fri Nov 23 15:12:30 CET 2007


On 23 Nov, 12:11, Greg Ewing <greg.ew... at canterbury.ac.nz> wrote:
> Georg Brandl wrote:

> from opendir import opendir
>
> print "READ"
> d = opendir(".")
> while 1:
>         name = d.read()
>         if not name:
>                 break
>         print "   ", name
> print "EOF"
>
> print "ITERATE"
> d = opendir(".")
> for name in d:
>         print "   ", name
> print "STOP"
>
> print "TELL/SEEK"
> d = opendir(".")
> for i in range(3):
>         name = d.read()
>         print "   ", name
> pos = d.tell()
> for i in range(3):
>         name = d.read()
>         print "   ", name
> d.seek(pos)
> while 1:
>         name = d.read()
>         if not name:
>                 break
>         print "   ", name
> print "EOF"

This is exactly the usage I was talking about.



More information about the Python-ideas mailing list