Ben Finney wrote:
Sturla Molden firstname.lastname@example.org writes:
I ask again: what would you expect (give an example) the output of this to be?
If I were to guess:
import __builtin__, fnmatch def dir(obj, glob=None):
... names = __builtin__.dir(obj) ... if glob is not None: ... names = fnmatch.filter(names, glob) ... return names ...
Example usage: what was the name of the function to remove a directory and all empty parents again?
import os dir(os)
[snip list with more than 200 names]
['read', 'readlink', 'removedirs', 'rmdir']
Ah, I think I remember it now...
What I am asking is if the need to filter the output from dir is so common that it could warrant a change to Python?
At the moment I'm writing list comprehensions in cases like the above, but I'd welcome the addition of a glob or regex argument to dir().
Given that we already have ways to filter a sequence built into the language, I doubt the need for a special way to filter the output from some particular function.