give an extension type a __dict__?
paul at fxtech.com
Wed Feb 21 00:25:25 CET 2001
Is it possible to give an extension type a __dict__ to store
type-specific constants? Assume we create a Point object in C:
PyTypeObject point_type_info =
0, // ob_size
"Point", // tp_name
sizeof(PointType), // tp_basicsize
0, // tp_itemsize
In Python, I can create one of these:
from point import Point
p = Point()
But since my Point type *acts* like I class, I'd like to scope some
constants into its namespace, so I can do this:
p = Point.ZERO
I realize I can put constants at the module scope in the module's
dictionary, but if I have many extension types, the global namespace
would be polluted.
Is this even possible?
More information about the Python-list