human
How can I tell if a file is a descendant of a given directory?
assistant
Here is some code to check if file `filename` is descendant of directory '/the/dir/'

os.path.commonprefix(['/the/dir/', os.path.realpath(filename)]) == '/the/dir/'

#Warning: this code generation is experimental. Please inspect the code for any bugs before executing.