Skip to content

Instantly share code, notes, and snippets.

@daGrevis
Created December 31, 2011 20:28
Show Gist options
  • Save daGrevis/1545249 to your computer and use it in GitHub Desktop.
Save daGrevis/1545249 to your computer and use it in GitHub Desktop.
Lists files and directories (like `ls` command does)
import sys, os
try:
root = sys.argv[1];
except IndexError:
root = '.'
for dirname, dirnames, filenames in os.walk(root):
for subdirname in dirnames:
print os.path.join(dirname, subdirname)
for filename in filenames:
print os.path.join(dirname, filename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment