#!/usr/bin/env python # Copyright 2005 Daniel Cer (daniel.cer@cs.colorado.edu) # # This work is licensed under the Creative Commons Attribution-NonCommercial- # ShareAlike License. To view a copy of this license, visit # http://creativecommons.org/licenses/by-nc-sa/2.5/ or send a letter to # Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, # 94105, USA. import os import sys import glob if len(sys.argv) != 2: print >>sys.stderr, "Usage:\n\t%s (directory to list)" % sys.argv[0] sys.exit(-1) dir_path = sys.argv[1] if not os.path.isdir(dir_path): print >>sys.stderr, "\"%s\" isn't a valid directory" % dir_path sys.exit(-1) print "Contents of \"%s\":" % dir_path for entry in (glob.glob("%s/*" % dir_path)): print "\t%s" % entry