[Python-3000] Class Decorators + ctypes (Was: yes to class decorators)
greg.ewing at canterbury.ac.nz
Fri Nov 17 03:52:52 CET 2006
> One unresolved issue is what exactly gets assigned to 'x' and 'y' at the
> time the class definition is evaluated.
Seems to me it ought to be some kind of descriptor.
It might be possible to do this reasonably without
any new syntax, e.g.
x = cfield("f")
y = cfield("f")
given a function cfield() that returns a suitable
> A different approach would be to say that the class decorator can
> overload the '__setattr__' method on the class itself during class creation:
But it doesn't work that way -- class attributes don't
go through __setattr__ during class creation. They go
into a dict that is passed to the type object's
constructor. The class doesn't even exist while the
class body is being evaluated.
More information about the Python-3000