How do I remove/unlink wildcarded files

Ben Finney ben+python at
Fri Jan 2 10:02:38 CET 2015

Anthony Papillion <anthony at> writes:

> I have a function I'm writing to delete wildcarded files in a
> directory.

Is the brute-force method (explicit, easy to understand) good enough?

    import os
    import os.path
    import glob

    paths_to_remove = glob.glob(
                os.path.expanduser("~anthony"), "backup", "unix*"
    for path in paths_to_remove:

 \           “In case you haven't noticed, [the USA] are now almost as |
  `\     feared and hated all over the world as the Nazis were.” —Kurt |
_o__)                                                   Vonnegut, 2004 |
Ben Finney

More information about the Python-list mailing list