New submission from David Halter:

I recently stumbled over the ``dir`` function not working correctly with 
classes. This means that ``dir(object)`` won't list ``object.__bases__`` or 
``object.__subclasses`` (and many other useful methods).

I think that we should change that. The C function ``type_dir`` (in 
``Objects/typeobject.c``) has a documentation entry which states:

"We deliberately don't suck up its __class__, as methods belonging to the 
metaclass would probably be more confusing than helpful."

I think that that's not true. The current behaviour of ``dir`` is way more 
confusing, since ``dir`` is typically the tool how we find out about magic 
methods.

I wrote about it in more details here: 
http://jedidjah.ch/code/2013/9/8/wrong_dir_function/

----------
components: Interpreter Core
messages: 197471
nosy: davidhalter
priority: normal
severity: normal
status: open
title: ``dir`` function does not work correctly with classes.
type: behavior
versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 
3.4, Python 3.5

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue19002>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to