I come to praise .join, not to bury it...

Donn Cave donn at u.washington.edu
Fri Mar 9 14:59:48 EST 2001


Quoth "Mark Pilgrim" <f8dy at yahoo.com>:
| "Alex Martelli" <aleaxit at yahoo.com> wrote in message
| news:98aspo024jg at news2.newsguy.com...
|> But the .join/.writelines parallel is VERY close, so why
|> would the SAME architectural choice (to have the sequence
|> object as an argument, accessing it through its ability
|> to enumerate its items, only) cause problems in one case
|> and not the other?!
|>
|> I think it's a misperception due to thinking of strings
|> as somehow 'passive', 'data', while a file-object is
|> thought of as 'active', 'a truly object-y object', or
|> something.
|
| Exactly!  I have taught Python to half a dozen people in the last few
| months, and every one of them had trouble with this concept, because they
| all came from a C background where they only thought of "string" as "packed
| array of char", or some other language (like Powerbuilder) where "string" is
| just a native datatype and isn't an object in any sense of the word.  Nobody
| minded file objects, even if they were only used to using integer file
| handles in their previous language.  I think that's because they could build
| a mental model of a file object as a kind of secretary who has a copy of a
| document on their desk and can read you various parts of it, or all of it,
| or tell you its title, or whatever.  But everybody had trouble with string
| objects, because the mental model is different.

At first it sounds like you're saying that's because of non-OOP
languages, but then those integer file handles come off like a
contradiction.  It isn't necessarily - the integer file descriptor
is actually a much more effective I/O abstraction in some ways,
because it comes from "the computer" and its devices.  On UNIX,
anyway, and for me that's one of the truly great things about UNIX.
In some common system programming situations, on UNIX, it's easier
even in Python to get things to work if you slough off the file
objects and go directly to the integer file descriptor.

My point, anyway, is that everywhere you look, you will find files
and I/O surrounded by software abstractions, if not OOP.  This is
somewhat different from the situation with strings, so not to be
surprised if some religious instruction is required.

	Donn Cave, donn at u.washington.edu



More information about the Python-list mailing list