Message130715
| Author |
loewis |
| Recipients |
Trundle, brian.curtin, eric.araujo, giampaolo.rodola, loewis, neologix, nvetoshkin, pitrou, socketpair, terry.reedy, torsten |
| Date |
2011年03月13日.00:43:13 |
| SpamBayes Score |
2.7909619e-11 |
| Marked as misclassified |
No |
| Message-id |
<4D7C131F.1050003@v.loewis.de> |
| In-reply-to |
<1299973501.23.0.232711689178.issue11406@psf.upfronthosting.co.za> |
| Content |
> The downsides of os.listdir: a) You can't get a peek at the files so
> far, it's all or nothing. I only wanted to know if a directory is
> empty and I have to read the whole thing just to throw it away (maybe
> I missed another library function?)
This depends somewhat on the operating system. On Unix, doing os.stat
on the directory, then looking on st_nlink, will tell you whether
the directory is empty (st_nlink is 2 on an empty directory).
> b) Using it in a GUI basically requires you to use threads if you may
> run into a dir with many files. Especially on a slow filesystem
> (network). Because you won't regain control until the whole thing is
> read.
Hmm. In a GUI, you would typically want to sort the file names by
some criterion, which typically requires you to read all files
(even if you then only display some of them).
> I would like to have an iterator version as well, but I also dislike
> another function (especially the "x" prefix). How about adding a
> keyword argument to select iterator behaviour?
I still would like to see a demonstrable improvement in a real-world
application. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2011年03月13日 00:43:14 | loewis | set | recipients:
+ loewis, terry.reedy, pitrou, giampaolo.rodola, eric.araujo, Trundle, brian.curtin, torsten, nvetoshkin, neologix, socketpair |
| 2011年03月13日 00:43:13 | loewis | link | issue11406 messages |
| 2011年03月13日 00:43:13 | loewis | create |
|