with open(os.path.expanduser('~/matches.txt'), 'w') as f:
    for dirpath, dirnames, filenames in os.walk(os.path.expanduser('~/x/y')):
        pass
equivalent to the find coreutil command in python 3 for recursively returning all files and folders in a directory structure?