"k r fry" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, I am new to this list, and also to Python. > I am trying to get Python to loop through the directory DATADIR which > contains the data I want to read. I get an error: "oserror [errno 20] > : Not a directory: "Katiescint.py"
That tells you that the code is finding a file called Katiescint.py in DATADIR and that youy are trying to treat it as a directory when it clearly isn't. But it's better to send the whole stacktrace error message in future since that tells us *where* the problem lies as well as what it is! > for subdir in os.listdir(DATADIR): #loop through list of listdir lists files as well as directories. > file=FITS.Read(DATADIR+'/'+subdir+'/flux.fits') > #opens flux.fits file and reads I'll need to take your word for that. I assume FITS is a module? and Read is a function within that module? All caps normally indicates a constant in Python - its only a convention but a pretty common one. And functions usually start in lowercase (and classes in uppercase) but again thats a convention and less rigorously followed. Also 'file' is a function (actually an alias for open() ) so using it as a variable name could cause confusion. > summation=open(DATADIR+'/'+subdir+'/flux.dat','w') #opens the > spotbyspot=open(DATADIR+'/'+subdir+'/spotflux.dat','w') #opens the And here is where you use the file as a directory and cause the error. HTH, -- Alan G Author of the learn to program web tutor http://www.freenetpages.co.uk/hp/alan.gauld _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor