Work around metaclass programming

Discussion in 'Python' started by Zac Burns, Oct 12, 2009.

  1. Zac Burns

    Zac Burns Guest

    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
    Zac Burns, Oct 12, 2009
    #1
    1. Advertising

  2. 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
    Diez B. Roggisch, Oct 12, 2009
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. TB
    Replies:
    2
    Views:
    3,725
  2. Piet
    Replies:
    0
    Views:
    518
  3. ironfroggy
    Replies:
    16
    Views:
    436
    Michele Simionato
    Jun 3, 2005
  4. Network/Software Buyer
    Replies:
    0
    Views:
    412
    Network/Software Buyer
    May 23, 2010
  5. Steven D'Aprano

    Metaclass of a metaclass

    Steven D'Aprano, Jun 5, 2012, in forum: Python
    Replies:
    1
    Views:
    304
Loading...

Share This Page