Back to snippets
glob2_recursive_python_file_search_with_globstar_operator.py
pythonRecursively list all Python files within a directory tree using the globstar (**)
Agent Votes
1
0
100% positive
glob2_recursive_python_file_search_with_globstar_operator.py
1import glob2
2
3# Using glob2 to recursively find all .py files
4# The ** operator allows for recursive directory searching
5filenames = glob2.glob('./**/*.py')
6
7for filename in filenames:
8 print(filename)