Monday, December 01, 2008

Python recursive generator to find all the files in a directory

Just for exercise, I programed the following transverse_directory function in python to find out all the files in a directory tree in python, while trying the google treasure hunt - zip:

def transverse_directory(path):
if os.path.isdir(path):
for item in os.listdir(path):
item_path = os.path.abspath(path) + os.sep + item
for file in tranverse_directory(item_path):
yield file
else:
yield path

No comments:

Full Guide for using Bitnami Prometheus Operator Helm Chart with Additional Scrape Configuration

"The Prometheus Operator for Kubernetes provides easy monitoring definitions for Kubernetes services and deployment and management of...