[Chicago] Reading From a Directory

Tim Ottinger tottinge at gmail.com
Tue May 10 19:35:46 CEST 2011

By now there have been plenty of responses suggesting glob and listdir
and the like.

The thing I didn't see was mention that opening a directory and
reading it certainly can be as "simple" as you say.  You can open it
as a binary file and try to figure out what the bytes mean.

Of course, in *nix world, most of the time a dir is a string and an
inode of some size. However, there are a great many non-*nix file
systems in use even in Linux world. Is it Fat16? NTFS? ExtXX?  Wanting
to read Windows directories is rather different than wanting to read

Do you really want to get below the compatibility layer to deal with
file system layouts, byte orderings, file allocation chains, journals,
and the like? Or do you just want to know what's in a directory?

I don't think you ever really described the problem well enough for me to know.

I suspect that either os.listdir() or os.walk() are what you want.

Finally "invoking a module" is "import" here, and that's almost
identical to "#include" in C.  I wouldn't consider it a hardship or an
exceptional expense.

Tim Ottinger, Sr. Consultant, Industrial Logic

More information about the Chicago mailing list