Deleting files with wildcards

Olivier Dagenais olivierS.dagenaisP at canadaA.comM
Wed Jul 26 16:10:18 EDT 2000


I will laugh so hard if, in a few weeks time, we see a Python virus going
around doing exactly this.  It would be the first totally portable virus,
now wouldn't it??  : )

--
----------------------------------------------------------------------
Olivier A. Dagenais - Carleton University - Computer Science III


"Alex Martelli" <alex at magenta.com> wrote in message
news:8lncs70240i at news2.newsguy.com...
> "Manfred Pisecky" <pisecky at tttech.com> wrote in message
> news:397f046d.193858654 at news.atnet.at...
> > Hello everyone!
> >
> > I have to delete a bundle of files, e.g. *.txt in a portable way (it
> > must work for Linux and NT).
> >
> > I use Python 1.5.2. and have not found a way to either delete files
> > with wildcards or to read the directory content (and do it file by
> > file).
> >
> > Is there a portable way in 1.5.2 ?
>
> os.listdir(path) will portably return the list of all files in
> the path, and os.unlink can be used to delete one or more of
> them (or, os.remove, too).  os.path.walk is also handy if you
> need to iterate on a whole subdirectory tree.
>
>
> Alex
>
>
>





More information about the Python-list mailing list