[Chicago] Reading From a Directory

Clyde Forrester clydeforrester at gmail.com
Tue May 10 20:20:18 CEST 2011


Tim Ottinger wrote:

> 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 wanted to get a list of files.

I thought it would be easiest to just open the directory and get the 
file names one by one, like I have done in so many (well, uh, 2 
actually) other languages. Sort of like when I want to go through a text 
file. Turns out I "just want to know what's in [the] directory". Yeah. 
All that commotion over this.
> 
> 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.
What I'm learning here is where language creators draw the line between 
built-ins and libraries/modules. Right now the focus is on the line 
between one part of the file system (files) and another part of the file 
system (directories). As others have pointed out, Guido seems to have 
spotted an important distinction here, and has seen no need to provide 
directory micro-management when there's no call for it.

What I've failed to realize, and therefore mention, is that my initial 
impression of the os.whatever() calls (as eluded to in various forum 
sites) was that it was an expedient, but crude shell-summoning hack. It 
looked a first like I would be asking for a ton of text, and then have 
to beat the snot out of it with regexps or something.

c4


More information about the Chicago mailing list