G
Giampaolo Rodola'
Hi,
I'm trying to implement a function which returns whether a path is a
subpath of another one (e.g. /a/b/c is a subpath of /a/b).
I wrote this function which apparently seems to work fine:
import os
def issubpath(path1, path2):
"""Return True if path1 is a sub path of path2."""
if path1 == path2:
return False
x1 = path1.split(os.sep)
x2 = path2.split(os.sep)
return x1[:len(x2)] == x2
....but if I use "issubpath('C:\\dir', 'C:\\')" it returns False.
A little help would be appreciated.
Thanks in advance.
--- Giampaolo
http://code.google.com/p/pyftpdlib/
I'm trying to implement a function which returns whether a path is a
subpath of another one (e.g. /a/b/c is a subpath of /a/b).
I wrote this function which apparently seems to work fine:
import os
def issubpath(path1, path2):
"""Return True if path1 is a sub path of path2."""
if path1 == path2:
return False
x1 = path1.split(os.sep)
x2 = path2.split(os.sep)
return x1[:len(x2)] == x2
....but if I use "issubpath('C:\\dir', 'C:\\')" it returns False.
A little help would be appreciated.
Thanks in advance.
--- Giampaolo
http://code.google.com/p/pyftpdlib/