python 2.7.12 on Linux behaving differently than on Windows

Marko Rauhamaa marko at pacujo.net
Fri Dec 9 13:40:14 EST 2016


Steve D'Aprano <steve+python at pearwood.info>:

> On Fri, 9 Dec 2016 09:34 pm, Marko Rauhamaa wrote:
>> Steve D'Aprano <steve+python at pearwood.info>:
>>> No that's incorrect. It isn't that . and .. are forbidden, but they
>>> are reserved: every single directory in Unix file systems have a .
>>> and .. directory entry. So they are legitimate directory names --
>>> they're just not names you can use for your own files, as they are
>>> already in use.
>> 
>> Same difference.
>
> Of course they are different.

You are not allowed to name your next file "." or ".." or "1/8".

>> you could have defined pathnames as lists of strings. Then,
>> everything would be unambigous and there wouldn't be any taboo or
>> reserved names.
>
> I really don't think so.
>
> So what path does [] represent?

That's the root directory.

> How do you distinguish between the root directory / and no pathname at
> all in a syntactically correct, unambiguous manner, using only lists?

I don't know what you mean.

> What path does [[]] represent? How about [[], []]?

Those are not lists of strings (see above).

> Here's a nice one for you to think about:
>
> L = []; L.append(L)
>
> What path does L represent?

That's not a list of strings.

> How would it be represented in the file system?
>
> What about this "path"? [None, 23, float('NAN'), {}]

That's not a list of strings.

> What's the difference between ['a', 'b', 'c'] and ['a', ['b', ['c']]] as
> path names?

Only the first one is a legal pathname.

> How do you represent the current and previous directory in a list
> without reserving identifiers for them?

My idea covered absolute pathnames only.

> How do you distinguish between '/home/steve' and '/home/steve/' for those
> programs that (rightly or wrongly) need to distinguish them?

I wouldn't. That distinction would have to be made some other way.

> How do you handle alternate data streams? Or versioning information, for
> systems like VMS that track that?

I am only talking about pathnames.

> What about file systems where you can have multiple roots? E.g. Windows, C
> \file versus D:\file and classic Mac Floppy:file and HardDrive:file?

I would only have one root.

> Do you really imagine that if Python were a shell, and required system
> administrators to write things like:
>
> mount ['dev', 'dvd'] ['mount', 'dvd']
>
> instead of
>
> mount /dev/dvd /mount/dvd
>
> that it would have been a success?

Dunno. I've been burned by bash so often that solid ground is what I
yearn for most.

>> BTW, guile allows *any* characters in an identifier. Even the empty name
>> is a valid identifier:
>
> And are Guile programs improved by having the empty string as an
> identify?

Point is, it's not at all impossible to remove the limitations on what
can go in names, filenames or otherwise.

> When was the last time you were coding and you thought "This program
> would be so much easier to understand and maintain if only I could
> name this the empty string"?

Having to be on constant lookout for corner cases is the problem.


Marko



More information about the Python-list mailing list