Python is white-space sensitive, so you need to make sure that everything you want inside the function is indented.
Stackoverflow has its own indentation requirements for code, which makes it hard to be sure what indentation your code originally had.
import os, glob
def fileDirectory():
#Asks the user for a file root directory
fileroot = raw_input("Please input the file root directory \n\n")
#Returns a list with all the files inside the file root directory
filelist = glob.glob(fileroot)
print filelist
fileDirectory()
The next thing is that glob returns a the results of a glob - it doesn't list a directory, which appears to be what you're trying to do.
Either you want os.listdir
, or os.walk
or you actually should ask for a glob expression rather than a directory.
Finally raw_input might give you some extra whitespace that you'll have to strip off. Check what fileroot is.
You might want to split up your program, so that you can investigate each function separately.
Douglas Leeder
2010-08-07 07:47:48