Please help me finding a way to implement os.path.issubpath(a, b)
Fredrik Lundh
fredrik at pythonware.com
Thu Sep 11 14:21:20 EDT 2008
Diez B. Roggisch wrote:
> Any reason why
>
> os.path.normpath(a).startswith(os.normpath(b)) doesn't do the trick?
Except for the trivial type, you mean? That depends on whether "c:\foo"
should be seen as a subpath to "c:\foobar" or not. I'd probably go for
(also untested):
def issubpath(a, b):
def fixpath(p):
return os.path.normpath(p) + os.sep
return fixpath(a).startswith(fixpath(b))
</F>
More information about the Python-list
mailing list