[Chicago] Reading From a Directory
Clyde Forrester
clydeforrester at gmail.com
Tue May 10 06:35:49 CEST 2011
Martin Maney wrote:
> On Mon, May 09, 2011 at 10:08:11PM -0500, Clyde Forrester wrote:
>> I'm making the tough mental shift from
>>
>> It's so trivially easy that everyone EXCEPT Python has the ability
>> to open, read, and close a directory. What could be easier?
>>
>> to
>>
>> Just because you CAN do it that way, doesn't mean you SHOULD. Or,
>> for that matter, that it's the most direct or simplest way.
>
> Well, you CAN do it that way... in, say, Perl. In C, C++, Python, and
> a horde of other languages, it's not a hardwired feature of the
> language, but an external function. Modules (and Packages) are
> Python's way of managing external code. In fact, despite the different
> appearances, ALL these languages "pass the buck" to the OS in the end:
> they only differ in how they present the slot for receiving the buck.
> And a bazillion other things are like this...
I don't think that you understand my objection. C has libraries for
opening and reading directories. Python does not. I have no objection to
modules, packages and libraries. What I'm objecting to is the notion
that Python can't inherently read directories. What goes on in the
module? Is it secret code? Is it in another language? Is Python's
standard solution to anything tricky to write a module in another
language and then invoke the module from Python? Most languages just
treat directories as a special sort of file, and just don't get all that
worked up.
>
>> Yeah, yeah. I'll get over it.
>
> I hope you do, because Python very generally prefers to package things
> into modules rather than making them builtins or keywords or whatever.
> You don't half know what Python is if you haven't gotten to know the
> standard library. Not know it all by heart - I doubt anyone does. But
> knowing that it's there, and how to find out what's in there that you
> don't already know about is not important, it's essential.
>
Again, you've misread my intent. I've gotten used to extensive modules
and libraries in languages like Java. That's not my complaint. That's
not what I'm getting used to. I'm getting used to the idea that I don't
have to actively read a directory end to end, so much as I just want to
get all of its contents. With files, much of the time one just wants the
whole thing also. But not always. If I'm doing a compare and it fails on
the first block, then boom, I'm done, it failed, no need to go on. But
with directories, there isn't a situation where I don't want to examine
the whole thing. That was a big blindspot in my mind, and that's what
I'm getting used to.
More information about the Chicago
mailing list