[Python-Dev] Python interface to attribute descriptors

Guido van Rossum guido@python.org
Thu, 14 Nov 2002 10:40:01 -0500


> Question: how could the descriptor "know" the name "x" if it is created
> by a descriptor-creating statement such as x = descriptor_creator(...).
> I guess one could do this by making a metaclass that would look for the
> descriptors in the class and "poke" the name into them but is there
> another way? In the example below I evaded this question by making the
> name an argument to positive's constructor.

Yes, those are the only ways I know of.  In retrospect it might have
been useful to give the descriptor API an extra argument for the
attribute name, but it's a bit late for that now.

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