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.