List directory tree structure in python?

Here’s a function to do that with formatting: import os def list_files(startpath): for root, dirs, files in os.walk(startpath): level = root.replace(startpath, ”).count(os.sep) indent=” ” * 4 * (level) print(‘{}{}/’.format(indent, os.path.basename(root))) subindent=” ” * 4 * (level + 1) for f in files: print(‘{}{}’.format(subindent, f))

jQuery find parent form

I would suggest using closest, which selects the closest matching parent element: $(‘input[name=”submitButton”]’).closest(“form”); Instead of filtering by the name, I would do this: $(‘input[type=submit]’).closest(“form”);