Detect file existance before open?

yinger ayinger1 at my-deja.com
Wed Nov 10 04:51:48 CET 1999


import os.path
os.path.isfile('<filename>')

will also work.

> import commands
> commands.getstatus('<filename>')
>
> In article <380c92a7.412580789 at 192.77.87.74>,
>   jlj at cfdrc.com (Lyle Johnson) wrote:
> > os.path.exists(filename)
> >
> > On Sat, 16 Oct 1999 21:06:07 -0600, "Bill Rodgers" <Bill at nospam.com>
> > wrote:
> >
> > >I would like to check for the existance of a file before I attempt
an
> open
> > >and maybe throw an exception.  I don't see a way to do this.  I
would
> like
> > >to tell the user that the file he specified doesn't exist.  Is
there
> a way
> > >to do this or do I need to catch the exception and deal with it
that
> way?
> > >Thanks,
> > >--
> > >Bill Rodgers
> > >Enterprise Management Consultant
> > >Specialty: BMC/Patrol
> > >brodg1 at ix.netcom.com
> > >
> > >
> >
> >
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>


Sent via Deja.com http://www.deja.com/
Before you buy.




More information about the Python-list mailing list