On Thu, Jun 30, 2011 at 9:38 PM, Sturla Molden email@example.com wrote:
Often when exploring an object with the 'dir' function, particularly in large packages like SciPy, I find that I need to filter the outout. Since a dir reminds me of a dos 'dir' or linux 'ls', a glob feels like the most natural to use.
For example, none of these would work:
dir(sp.fft.i*) # syntax error dir('sp.fft.i*') # returns the attributes a string
import fnmatch def glob_dir(obj, pattern): return fnmatch.filter(dir(obj), pattern)
['capitalize', 'center', 'count']
If it's something you use often, drop it into a utility module or PYTHONSTARTUP