Python Glob
The module glob (in Python) is what you want to be using if you are trying to use wildcards with Python.
glob.glob()
In case you need to learn or review about wildcards (in Mac OS X): koldfyre’s tutorial.
And here is the official site with slightly complicated explanations.
EDIT:
Because of the *relative* popularity this post has been getting, here is some examples and explanations of applications of Python globbing.
import os
os.getcwd() # gets current working directory - the equivalent of pwd
import glob
glob.glob('*') # lists all files in the current directory python is running in
glob.glob('*.jpg') # returns all jpeg images
glob.glob('[a-z]????.*') # lists all files starting with a letter, followed by 4 characters (numbers, letters) and any ending.
Maybe people like this post because of the cool “glob” name…
| Posted 1 year, 2 months agoMaybe they like it because it gives good, clear examples.
– Zog
| Posted 6 months, 1 week ago