[Tutor] Fwd: Help with basic user-data file

Kent Johnson kent37 at tds.net
Thu Oct 12 23:04:59 CEST 2006


> From: Asrarahmed Kadri <ajkadri at googlemail.com>
> Date: Oct 12, 2006 9:17 AM
> Subject: Re: [Tutor] Help with basic user-data file
> To: Rob Andrews <rob.andrews at gmail.com>
> 
> 
> Thanks.
> Can you please also tell me how to check the existence of a file using
> python builtin functions.

If path is a string containing the full path to the file (absolute path 
or relative to the working dir) then use
import os
os.path.exists(path) # To see if the path represents *something* real
os.path.isfile(path) # check for a file specifically
os.path.isdir(path)  # check for a directory

Kent




More information about the Tutor mailing list