Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Work around metaclass programming

Reply
Thread Tools

Work around metaclass programming

 
 
Zac Burns
Guest
Posts: n/a
 
      10-12-2009
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
 
Reply With Quote
 
 
 
 
Diez B. Roggisch
Guest
Posts: n/a
 
      10-12-2009
Zac Burns schrieb:
> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Metaclass of a metaclass Steven D'Aprano Python 1 06-05-2012 03:30 PM
Microsoft & patents: what goes around comes around... Lawrence D'Oliveiro NZ Computing 104 12-16-2006 07:11 AM
Read all of this to understand how it works. then check around on otherRead all of this to understand how it works. then check around on other thelisa martin Computer Support 2 08-18-2005 06:40 AM
metaclass that inherits a class of that metaclass? ironfroggy Python 16 06-03-2005 10:00 AM
Make wxListCtrl fit around contents and parent frame fit around listctrl Piet Python 0 07-18-2004 08:27 AM



Advertisments