best way to check if a file exists?
jim-on-linux
inq1ltd at verizon.net
Wed Nov 1 00:04:45 EST 2006
On Tuesday 31 October 2006 16:01, John Salerno
wrote:
> What is the best way to check if a file already
> exists in the current directory? I saw
> os.path.isfile(), but I'm not sure if that does
> more than what I need.
>
> I just want to check if a file of a certain
> name exists before the user creates a new file
> of that name.
>
> Thanks.
How about something like one of these;
if os.path.isfile(vfileName) not True :
male file
or
if os.path.isfile (os.path.join(os.getcwd(),
vFileName) )==True :
do something
jim-on-linux
http://www.inqvista.com
More information about the Python-list
mailing list