[Python-ideas] os.path.commonprefix: Yes that old chestnut.

random832 at fastmail.us random832 at fastmail.us
Tue Mar 24 14:36:23 CET 2015


On Tue, Mar 24, 2015, at 06:05, Paul Moore wrote:
> One thing my implementation doesn't (yet) handle is case sensitivity.
> The common prefix of WindowsPath('c:\\FOO\\bar') and
> WindowsPath('C:\\Foo\\BAR') should be WindowsPath('C:\\Foo'). But not
> for PosixPath. (And again, when they are mixed, which is silly but
> possible, what behaviour should apply? "Work like self" is the obvious
> answer if we have a method).

So, speaking of windows path oddities... what should be done for paths
where one has a drive and the other does not? No common prefix?
Interpret as the current drive? Do the former for pure paths and the
latter for concrete paths? Pass in an option?

Keeping in mind that people may write "portable" code but put in no
effort to specifically support windows.

> And again, when they are mixed, which is silly but possible, what behaviour should apply

For concrete paths, using the actual names of the files if they exist
would be another option.


More information about the Python-ideas mailing list