[path-PEP] Path inherits from basestring again

Reinhold Birkenfeld reinhold-birkenfeld-nospam at wolke7.net
Sat Jul 30 19:06:37 CEST 2005

Steven D'Aprano wrote:
> On Sat, 30 Jul 2005 14:10:52 +0200, Reinhold Birkenfeld wrote:
>> Above all, nobody can tell me that there's any programmer who doesn't 
>> instantly recognize '/' as a directory separator.
> Is classic Macintosh OS still supported on Python? Because Mac programmers
> who haven't made the jump to OS X will probably instantly recognise ':' as
> the directory separator, not '/'.
> Acorn RISC OS developers may also instantly recognise '.' as the directory
> separator.

I didn't say that '/' is the native directory separator on every platform. But
other than ':' or '.', '/' is used as widely as URLs are, so it _will_ be
recognizable as a directory separator.

> And presumably mathematicians and numeric programmers who do very little
> file input/output will probably instantly recognise '/' as the division
> operator.

Yes, they will. But they presumably will read the documentation of the path
module when using it (and, given that most operands will be strings, they won't
suspect division going on).

> And I have no idea what directory separators are in use under file systems
> that don't use ASCII or any extension to ASCII, eg the OS which has been
> described as the most common operating system in the world, the Japanese
> "Real-time Operating System Nucleus", TRON. (Chances are you have at least
> half a dozen devices in your home with embedded TRON.)

Well, as long as Python doesn't run under TRON, that's not much of a point here.

> Still, your (modified) point that most Western programmers will quickly
> recognise '/' as a directory separator is surely true. 
> Even given that, I'm not convinced that it is a good idea to turn '/' into
> a join-path operator. I don't have any good reasons for objecting
> either, just a funny little feeling in the back of my head that says
> that no good can ever come from allowing Path("C:\Windows")/"cmd.com".

Well, if you want to do such things, you surely don't need a path join anyway.

Just write "C:\\Windows\\" + something in this case. The path join is there
for platform independence, and you will most certainly not write a Windows
path directly into the source if you want to be XP compatible.


More information about the Python-list mailing list