On Sun, May 20, 2012 at 4:55 PM, Meador Inge <mead...@gmail.com> wrote: > On Tue, May 15, 2012 at 3:13 PM, Christian Tismer <tis...@stackless.com> > wrote: > >> Is the usage of dir() correct in this context or is the doc right? >> It would be nice to add a sentence of clarification if the use of >> dir() is in fact the correct way to implement inspect. > > There is already a note in the inspect.getmembers documentation > (http://docs.python.org/library/inspect.html#inspect.getmembers): > > """ > Note > > getmembers() does not return metaclass attributes when the argument is > a class (this behavior is inherited from the dir() function). > """ > > In any case, open a tracker issue if you think the documentation needs > to be improved or that there might be a bug. > > -- Meador
I have to agree with Christian that inspect.py is full of hacks and heuristics that would be fine in a module that's part of a user's app or even in a library, but stand out as brittle or outright unreliable in a stdlib module. Basically, you can't trust that inspect.py will work. I've seen various occasions (sorry, can't remember details) where some function in it outright crashed when given a slightly unusual (but not unreasonable) argument. It might be a nice project for a new contributor to improve this situation. -- --Guido van Rossum (python.org/~guido) _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com