[Python-ideas] dir with a glob?
Steven D'Aprano
steve at pearwood.info
Thu Jun 30 17:54:29 CEST 2011
Nick Coghlan wrote:
> On Thu, Jun 30, 2011 at 11:27 PM, Sturla Molden <sturla at molden.no> wrote:
>> 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?
>
> No, if an object is complicated enough that pprint(dir(obj)) and
> help(obj) aren't adequate to explore it, then it is time to go read
> the documentation (or the source, if the documentation is lacking).
Do you think that *reading the source* is to be preferred over a simple
tool like running a filter over the output of dir()? I'm not exactly
sure what point you're trying to make, but I don't think it's a good one.
> The interactive prompt is just one of the available tools for code
> exploration, it doesn't make sense to try to make it do everything.
But the interactive prompt already does everything. Anything you can do
in Python can be done at the prompt. The question we are asking is not
should users be able to filter the output of dir, because of course they
can. The question we are asking is, should there be One Obvious Way to
filter the output of dir, rather than the status quo (people do without,
reinvent the wheel, or struggle with non-obvious, inconvenient and
verbose ways).
I'm +1 on adding a glob filter to dir.
--
Steven
More information about the Python-ideas
mailing list