Why the first //
are not removed ?
The following code:
import os
os.path.normpath('//var//lib/')
returns
'//var/lib'
not
'/var/lib'
Here the definition:
normpath(path)
'''Normalize path, eliminating double slashes, etc.'''
Because on Windows, there is a path ambiguity that python preserves.
//var/whatever
could refer to a drive mounted as the name //var
OR
/var/whatever
could refer to a local drive directory.
If python collapsed leading double slashes, you could unknowingly change a path to refer to a different location.
Another way of saying this is that //var
and /var
are fundamentally different paths, and python treats them differently. You should probably change your test case to reflect this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With