Skip to main content

A fork of fnmatch to implement **

Project description


This library is a fork of fnmatch ( to implement **


All documentation is identical to fnmatch except * , * is now ** and * only affects the particular directory


pip install pywildcard

Link pypi:


import pywildcard
dirs = ['hello/', 'hello/world.pyc', 'hello/world/other/folder/']
pywildcard.filter(dirs, 'hello/*')
# ['hello/', 'hello/world.pyc']

pywildcard.filter(dirs, 'hello/*.py')
# ['hello/']

pywildcard.filter(dirs, 'hello/**')
# ['hello/', 'hello/world.pyc', 'hello/world/other/folder/']

pywildcard.filter(dirs, 'hello/**.py')
# ['hello/', 'hello/world/other/folder/']

Diffs fnmatch & pywildcard


import re
import fnmatch

urls = ['example/l1/l2/',

regex = fnmatch.translate('example/*')
# 'example\\/.*\\Z(?ms)'
re.findall(regex, "\n".join(urls))
# return ['example/l1/l2/\nexample/l1/\nexample/l1/\nexample/l1/l2/l3/']


import re
import pywildcard

urls = ['example/l1/l2/',

regex = pywildcard.translate('example/**')
# 'example/.*?$(?ms)'
re.findall(regex, "\n".join(urls))
# return ['example/l1/l2/',
#         'example/l1/',
#         'example/l1/',
#         'example/l1/l2/l3/']

Running the unit tests

```bash # Check out the git repository. git clone # Enter the directory. cd python-wildcard # Install pytest if you have not done already. pip install pytest # Run the tests pytest


1.0.8 (2015-11-26)

  • update

1.0.7 (2015-11-25)

  • Add documentation

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pywildcard, version 1.0.10
Filename, size & hash File type Python version Upload date
pywildcard-1.0.10.tar.gz (3.6 kB) View hashes Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page