[Chicago] Reading From a Directory

JongMan Koo jongman at gmail.com
Tue May 10 01:35:21 CEST 2011


Well, this was the first link on my google search "python list directory":

http://stackoverflow.com/questions/120656/directory-listing-in-python

It doesn't say it's mad..

--JongMan

2011/5/9 Clyde Forrester <clydeforrester at gmail.com>

> What I want to do is open a directory and read file names from it.
>
> The standard answer I get by Googling seems to be:
> No you don't. Are you mad? Why would you want to do that? Clearly you want
> to do something else. It's a scripting language and you have no business
> "programming" in it. Why don't you just pass the buck to a shell (os.popen)
> and handle it that way? Or use a magic module glob.glob) to get a complete
> list, or something.
>
> Perl and Ruby have directory classes with open, read, and close methods.
> Why doesn't Python?
>
> Now it does occur to me that any time I want to read from a directory, I
> want all the files. Even if I'm using a wild card, I want to apply it to all
> the files in the directory, not just the first one or two. But somehow
> calling out to a shell, or invoking a module seems as "easy" as hiring a
> subcontractor to tie my shoes. I don't things have to get that complicated.
>
> c4
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> http://mail.python.org/mailman/listinfo/chicago
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/chicago/attachments/20110509/0dc5c00b/attachment.html>


More information about the Chicago mailing list