>>> import fnmatch >>> fnmatch.translate('*.(bat|com|exe)') '(?s:.*\\.\\(bat\\|com\\|exe\\))\\Z'