[Python-ideas] dir with a glob?
Nick Coghlan
ncoghlan at gmail.com
Fri Jul 1 02:23:27 CEST 2011
On Fri, Jul 1, 2011 at 10:17 AM, Ben Finney <ben+python at benfinney.id.au> wrote:
> Steven D'Aprano <steve at pearwood.info> writes:
>
>> 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.
>
> I understood Nick's meaning to entail that in such a circumstance where
> usage for a complex object is difficult to discover, the solution isn't
> to alter Python but to address the poor documentation and/or poor design
> of those complex objects.
Yeah, that's about it - dir-based exploration hits a point of
diminishing returns where it becomes better to go find a source of
information that doesn't require you to explicitly request each piece
of additional data.
However, I found Steven and Georg's point about "how do I spell that
again?" for objects with a broad API much more compelling, since I
*have* been in that situation many, many times. It's not exploration
in that case, it's a dir-based equivalent of code completion support.
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-ideas
mailing list