[Python-ideas] dir with a glob?
grosser.meister.morti at gmx.net
Thu Jun 30 15:09:46 CEST 2011
I would rather add a grep method to regular expression objects:
for s in sequence:
And a global function to the re module:
Then you could do:
Yes, it would be more to type but it would be more general.
OT: I think it would be good if regular expressions would be callable with this method:
return self.search(s) is not None
Then one could use it in a filter expression:
On 06/30/2011 01:38 PM, Sturla Molden 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
> I believe a new dir functions is needed, or a change in the behviour of the current version.
> Of course a 'glob aware dir function' can be implemented by monitoring the call stack (cf.
> sys._getframe().f_back), but I think the problem is general enough to warrant an official sultion.
More information about the Python-ideas