On Thu, Nov 5, 2009 at 7:41 PM, Peng Yu <pengyu...@gmail.com> wrote: > I looked though the os.path manual. I don't find a function that can > test if a path is in a directory or its sub-directory (recursively). > > For example, /a/b/c/d is in /a its sub-directory (recursively). Could > somebody let me know if such function is available somewhere?
Couldn't you just canonicalize the paths using os.path.abspath() and friends and then do subdirectory.startswith(parent_directory) [as strings]? Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list