Re: Please help me finding a way to implement os.path.issubpath(a, b)

2008-09-12 Thread Giampaolo Rodola'
On Sep 11, 8:04 pm, Arnaud Delobelle [EMAIL PROTECTED] wrote: On Sep 11, 5:40 pm, Giampaolo Rodola' [EMAIL PROTECTED] wrote: 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

Please help me finding a way to implement os.path.issubpath(a, b)

2008-09-11 Thread 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 ==

Re: Please help me finding a way to implement os.path.issubpath(a, b)

2008-09-11 Thread Arnaud Delobelle
On Sep 11, 5:40 pm, Giampaolo Rodola' [EMAIL PROTECTED] wrote: 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,

Re: Please help me finding a way to implement os.path.issubpath(a, b)

2008-09-11 Thread Diez B. Roggisch
Giampaolo Rodola' schrieb: 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

Re: Please help me finding a way to implement os.path.issubpath(a, b)

2008-09-11 Thread Fredrik Lundh
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):