os.path and Path
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Thu Jun 16 03:58:55 EDT 2011
On Thu, 16 Jun 2011 09:03:58 +0200, Laurent Claessens wrote:
>> So, I suppose I shall have to let go of my dreams of
>>
>> --> Path('/some/path/and/file') == '\\some\\path\\and\\file'
>>
>> and settle for
>>
>> --> Path('...') == Path('...')
>>
>> but I don't have to like it. :(
>
>
> Why not define the hash method to first convert to '/some/path/and/file'
> and then hash ?
It's not so simple. If Path is intended to be platform independent, then
these two paths could represent the same location:
'a/b/c:d/e' # on Linux or OS X
'a:b:c/d:e' # on classic Mac pre OS X
and be impossible on Windows. So what's the canonical path it should be
converted to?
--
Steven
More information about the Python-list
mailing list