[Python-Dev] A couple of quick type system questions

Guido van Rossum guido@python.org
Sat, 11 May 2002 10:40:15 -0400


> > ob_type has the type PyType_Object *, and a PyType_Object has a
> > tp_dict pointer, so I think the answer is that every /type/ has a dict.
> > 
> Huh?
> 
> tp_dict of int (_PyInt_Type) is NULL.

Huh?  Not for me:

[guido@pcp742651pcs guido]$ python2.2
Python 2.2.1 (#19, Apr 29 2002, 16:14:02) 
[GCC 2.96 20000731 (Red Hat Linux 7.1 2.96-98)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print int.__dict__.keys()
['__int__', '__ror__', '__rtruediv__', '__add__', '__str__', '__getattribute__', '__radd__', '__rmul__', '__truediv__', '__rrshift__', '__rsub__', '__rdiv__', '__and__', '__rmod__', '__abs__', '__float__', '__rshift__', '__rand__', '__new__', '__rlshift__', '__cmp__', '__pos__', '__rfloordiv__', '__doc__', '__mul__', '__rpow__', '__rdivmod__', '__invert__', '__coerce__', '__pow__', '__divmod__', '__lshift__', '__hex__', '__oct__', '__rxor__', '__nonzero__', '__mod__', '__neg__', '__xor__', '__div__', '__repr__', '__floordiv__', '__hash__', '__sub__', '__long__', '__or__']
>>> 

--Guido van Rossum (home page: http://www.python.org/~guido/)