Staging
v0.8.1
https://github.com/python/cpython
Revision 5d2b77cf31c5a3cbabc74936831480b9caea3a12 authored by Tim Peters on 03 September 2001, 05:47:38 UTC, committed by Tim Peters on 03 September 2001, 05:47:38 UTC
bag.  It's clearly wrong for classic classes, at heart because a classic
class doesn't have a __class__ attribute, and I'm unclear on whether
that's feature or bug.  I'll repair this once I find out (in the
meantime, dir() applied to classic classes won't find the base classes,
while dir() applied to a classic-class instance *will* find the base
classes but not *their* base classes).

Please give the new dir() a try and see whether you love it or hate it.
The new dir([]) behavior is something I could come to love.  Here's
something to hate:

>>> class C:
...     pass
...
>>> c = C()
>>> dir(c)
['__doc__', '__module__']
>>>

The idea that an instance has a __doc__ attribute is jarring (of course
it's really c.__class__.__doc__ == C.__doc__; likewise for __module__).

OTOH, the code already has too many special cases, and dir(x) doesn't
have a compelling or clear purpose when x isn't a module.
1 parent 95c99e5
History
Tip revision: 5d2b77cf31c5a3cbabc74936831480b9caea3a12 authored by Tim Peters on 03 September 2001, 05:47:38 UTC
Make dir() wordier (see the new docstring). The new behavior is a mixed
Tip revision: 5d2b77c
File Mode Size
Demo
Doc
Grammar
Include
Lib
Mac
Misc
Modules
Objects
PC
PCbuild
Parser
Python
RISCOS
Tools
.cvsignore -rw-r--r-- 109 bytes
.hgtags -rw-r--r-- 2.1 KB
LICENSE -rw-r--r-- 12.0 KB
Makefile.pre.in -rw-r--r-- 25.4 KB
PLAN.txt -rw-r--r-- 12.2 KB
README -rw-r--r-- 38.1 KB
acconfig.h -rw-r--r-- 6.8 KB
configure -rwxr-xr-x 198.1 KB
configure.in -rw-r--r-- 47.0 KB
install-sh -rwxr-xr-x 5.5 KB
pyconfig.h.in -rw-r--r-- 18.3 KB
setup.py -rw-r--r-- 29.6 KB

README

back to top