[Python-ideas] os.path.isparent and os.path.ischild
Oleg Broytman
phd at phdru.name
Fri Jul 8 11:25:24 CEST 2011
On Fri, Jul 08, 2011 at 06:00:26PM +1000, Steven D'Aprano wrote:
> def isparent(path1, path2):
> "Returns True if path1 is a parent of path2."
> return os.path.commonprefix([path1, path2]) == path1
>>> isparent('C:\\Program Files', 'C:/Program Files/Python')
False
Oops...
Oleg.
--
Oleg Broytman http://phdru.name/ phd at phdru.name
Programmers don't die, they just GOSUB without RETURN.
More information about the Python-ideas
mailing list