[Python-ideas] A user story concerning things knowing their own names

Greg Ewing greg.ewing at canterbury.ac.nz
Sat Mar 19 02:37:32 CET 2011


Guido van Rossum wrote:

> There's another pattern where all class attributes that have a certain
> property are also collected in a per-class datastructure,

I think __addtoclass__ could cover those as well,
if you can arrange for the relevant objects to inherit
from a class having an appropriate __addtoclass__
implementation.

If that's not convenient, another approach would be to
wrap them in something whose __addtoclass__ does the
right thing and then unwraps itself.

-- 
Greg



More information about the Python-ideas mailing list