[Python-Dev] can't set attributes of built-in/extension type

Greg Ewing greg.ewing at canterbury.ac.nz
Sun Feb 24 08:35:51 CET 2008


Neal Becker wrote:
> (Or, help me understand, what is the difference between a type that I create
> using python C api and a python class?)

Classes that you create in Python have a __dict__ attribute
holding a dictionary for arbitrary attributes to go in.

Most types defined in C don't bother providing a __dict__,
since one doesn't normally need to add arbitrary
attributes to them, and the overhead would be almost
completely wasted.

-- 
Greg


More information about the Python-Dev mailing list