[Python-ideas] Should we improve `dir`?
dreamingforward at gmail.com
Sun Sep 15 03:37:05 CEST 2013
> I recently stumbled over `dir()` not working correctly in the case of
Not working correctly? That would imply an adequate definition of
Dir should divulge all method and attribute names of a class -- a
"directory", as it were. In my opinion, it should not report
__bases__, __name__, __doc__, or __class__ -- all of which are
meta-things not meant for the user of a class. If a programmer wants
to see more, then the inspect module would presumably be appropriate,
or simply calling for help().
> In short:
> `dir` doesn't list the `type` methods, which it should in my opinion,
> because there are very important attributes in there like `__name__` or
> This led to some confusion in the past, e.g.
> The long version is in the above link.
> After discussions, I realized that I should probably bring this up in
> python-ideas, I think the current implementation can be very confusing for
> people trying to introspect classes with `dir`, which is IMHO its typical
> use case.
> Python-ideas mailing list
> Python-ideas at python.org
More information about the Python-ideas