Work around metaclass programming

Z

Zac Burns

I have a class called Signal which is a descriptor. It is a descriptor
so that it can create BoundSignals, much like the way methods work.
What I would like to do is to have the class be a descriptor when
instantiated in what will be the locals of the class, but not a
descriptor everywhere else.

Can I do this without requiring the class to use a special metaclass
that does the transformation?

One way I can think of which would work if there is such a thing would
be a hook that type will call on the value of locals if that value is
defined. That way I could just return the descriptor from that hook.
The advantage of this over using a metaclass is that these are
combinable.

Am I making sense?

--
Zachary Burns
(407)590-4814
Aim - Zac256FL
Production Engineer (Digital Overlord)
Zindagi Games
 
D

Diez B. Roggisch

Zac said:
I have a class called Signal which is a descriptor. It is a descriptor
so that it can create BoundSignals, much like the way methods work.
What I would like to do is to have the class be a descriptor when
instantiated in what will be the locals of the class, but not a
descriptor everywhere else.

Can I do this without requiring the class to use a special metaclass
that does the transformation?

One way I can think of which would work if there is such a thing would
be a hook that type will call on the value of locals if that value is
defined. That way I could just return the descriptor from that hook.
The advantage of this over using a metaclass is that these are
combinable.

Am I making sense?

Not to me. What do you mean by "locals of the class", and how is a class
to be instantiated in them? Can you describe what your *usecase* for
this is?

Diez
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top