how do i check if a file exists with python?
slhath at home.com
Thu Dec 28 21:42:51 CET 2000
Thanks for both responses!
It helps to know where to look.
"David C. Ullrich" <ullrich at math.okstate.edu> wrote in message
news:92g5v8$r5k$1 at nnrp1.deja.com...
> In article <RlM26.98766$yR4.2639444 at news1.rdc1.tx.home.com>,
> "Scott Hathaway" <slhath at DownWithSpam.home.com> wrote:
> > I have searched Deja, looked in two pyton books, and searched the
> > site trying to find out this simple question.
> Have you tried the _documentation_?
> > Can someone please give me the call and the module it lives in?
> I don't recall what it is exactly...[five minutes later]:
> One way is with glob:
> import glob
> def FileExists(filename):
> return len(glob.glob(filename)) > 0
> if FileExists(r'c:/windows/notepad.exe'):
> print 'yup'
> if not FileExists(r'c:/windows/notepad.exk'):
> print "I didn't think so."
> May or may not be the Right way.
> > Thanks,
> > Scott
> Oh, dejanews lets you add a sig - that's useful...
> Sent via Deja.com
More information about the Python-list