Piet van Oostrum wrote:
Steven D'Aprano <ste...@remove.this.cybersource.com.au> (SD) wrote:

SD> What you describe is impossible -- os.listdir() returns an ordinary list, SD> it isn't a lazy iterator that updates automatically as the directory SD> changes. (At least not in Python2.5 -- I haven't checked Python 3.1.)

He's not using Python3, see the print statement and the file function.
But even with the appropriate changes the behaviour will be the same in
3.1 as in 2.x.

I think Steven may be remembering the conversation here on c.l.p a month or two back where folks were asking to turn os.listdir() into an iterator (or create an os.xlistdir() or os.iterdir() function) because directories with lots of files were causing inordinate slowdown. Yes, listdir() in both 2.x and 3.x both return lists while such a proposed iterator version could be changed on the fly by interim file/directory creation.

-tkc





--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to