Shell style globbing instead or re syntax?

Daniel Dittmar daniel.dittmar at sap.com
Tue Aug 13 18:32:25 CEST 2002


bruce edge wrote:
> I'd doing a command line interface thingy in python.
> I want to support expressions for args, while I like python's re
> syntax, it's not what users expect.
> They're more used to bash style globbing. Is there a lib somewhere
> that I can use for this?
> glob doesn't work because it only works on filenames.

Use fnmatch.translate:
def translate(pat):
    """Translate a shell PATTERN to a regular expression.

    There is no way to quote meta-characters.
    """

Daniel






More information about the Python-list mailing list