trouble with os.path.exists() and wildcards

Jeremy Fincher tweedgeezer at hotmail.com
Tue Nov 18 10:19:57 EST 2003


Erik Max Francis <max at alcyone.com> wrote in message news:<3FB91D06.5DCB381 at alcyone.com>...
> Jeremy Fincher wrote:
> 
> > Erik Max Francis <max at alcyone.com> wrote in message
> > news:<3FB8A5B8.3D359C27 at alcyone.com>...
> >
> > > Fernando Rodriguez wrote:
> > >
> > > > How can I check for the xistence of any file that matches a
> > > > wildcard?
> > > >
> > > > For example: ppis-*.iss
> > > >
> > > > os.path.exists() doesn't expand the wildcard...
> > >
> > > Use glob.glob and then os.path.exists in a loop.
> > 
> > Wouldn't the glob.glob only return files that actually exist?
> 
> Sure, but isn't that what he wants?  He wrote, "the [existence] of any
> file that maches a wildcard."  He's obviously talking about existing
> files.

Ah, you misunderstand; my problem was with the "and then
os.path.exists in a loop" part, since, by definition, the files
returned by glob.glob will exist :)  I was just trying to kindly point
out that os.path.exists isn't needed for his purposes.  I guess I
could've been more clear :)

Jeremy




More information about the Python-list mailing list