import os
from fnmatch import fnmatch
def glob(pattern, recursive = True):
result = []
dirname, pattern = os.path.split(pattern)
for path, dirs, files in os.walk(dirname):
result.extend(os.path.join(path, f) for f in files if fnmatch(f, pattern))
if not recursive:
del dirs[:]
return result