[Tutor] Check for file in different dirs

bob gailer bgailer at gmail.com
Thu Jul 24 20:36:50 CEST 2008


Timo wrote:
> I want to check for a file in 3 directories. If the file is found in 1 
> of the dirs then do something, if the file was found in 2 or 3 dirs, 
> then do something else. I know the paths and filename. How can this be 
> done?

We like to give a hand and prefer not to write programs.

So I suggest you write as much of the program as you can, then show it 
to us and tell us where you are stuck. I assume you have enough Python 
knowledge to get a start. If you are new to Python then at least present 
a program design.

Take a look at the os.path module and its exists function. That is what 
you use to see if a file exists.

-- 
Bob Gailer
919-636-4239 Chapel Hill, NC



More information about the Tutor mailing list