Skip to content

Instantly share code, notes, and snippets.

@seanh
Created March 18, 2009 14:26
Show Gist options
  • Save seanh/81152 to your computer and use it in GitHub Desktop.
Save seanh/81152 to your computer and use it in GitHub Desktop.
Recursively walk a directory in Python with os.walk.
"""Recursively walk a directory with os.walk."""
import os
base_dir = '/home/seanh' # The directory to walk
for root, dirs, files in os.walk(base_dir):
print 'root: ',root
print ' dirs:'
for d in dirs:
print ' ',d
print ' files:'
for f in files:
print ' ',f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment