k r fry wrote: > Sorry for not copying the whole traceback before, I hop I have done it > right this time. > > I am now getting: > > Traceback (most recent call last): > File "katiescint.py", line 153, in ? > for subdir in os.path.istdir(DATADIR): #loop through > list of strings > AttributeError: 'module' object has no attribute 'istdir' > > I did think maybe it was meant to be "listdir" instead of "istdir", but > that doesn't work either. > Sorry to be a pain.
You'll get the hang of it... :-) There are two functions required here: os.listdir(), and os.path.isdir(). The first one is the correct one for the purpose, as you originally used it. The second one (which I suppose someone with a German background might try to spell "istdir" ;-) ) is to test whether a given path "is [a] dir[ectory]". If you read the documentation on those two functions, and experiment at the interactive prompt, you'll shortly notice that os.listdir() returns only the names of the items in the directory, not the full paths. os.path.isdir(), on the other hand, requires a full path (since of course it can't know what directory you looked in with os.listdir), so you'll have to join the names together before testing them, something like this (and I'll rely on you to actually *read the docs* and *experiment at the interactive prompt* this time, instead of giving up so quickly and asking for help again when you could figure this out yourself with a little more effort): for name in os.listdir(DATADIR): path = os.path.join(DATADIR, name) if os.path.isdir(path): filename = os.path.join(path, 'flux.fits') data = FITS.Read(filename) # etc.... -Peter -- http://mail.python.org/mailman/listinfo/python-list