[Python] How would you implement ant-style patternsets in python to select groups of files?

Discussão em 'Python' iniciado por Stack, Maio 5, 2025.

  1. Stack

    Stack Membro Participativo

    Ant has a nice way to select groups of files, most handily using ** to indicate a directory tree. E.g.

    **/CVS/* # All files immediately under a CVS directory.
    mydir/mysubdir/** # All files recursively under mysubdir


    More examples can be seen here:

    http://ant.apache.org/manual/dirtasks.html

    How would you implement this in python, so that you could do something like:

    files = get_files("**/CVS/*")
    for file in files:
    print file

    =>
    CVS/Repository
    mydir/mysubdir/CVS/Entries
    mydir/mysubdir/foo/bar/CVS/Entries

    Continue reading...

Compartilhe esta Página