H
H Jansen
I try to work out how to use __new__ and metaclass (or __metaclass__)
mechanisms in order to change the base class at runtime. I haven't been
successful so far, however, even after also reading most of the relevant
documentation.
The most simple representation (an oversimplification indeed) of what
I'm trying to accomplish is this:
class Base1:
pass
class Base2:
pass
class Meta:
pass
class Good(Meta):
pass
What I want to achieve at runtime is this:
g1 = Good(Base1) # a Good object with base class Base1
g2 = Good(Base2) # a Good object with base class Base2
Of course, this oversimplified (pseudo-code) example will not work but
illustrates most clearly my idea. How can I come closest to realizing
this by using the above mechanisms?
Thanks
--Henk
--
mechanisms in order to change the base class at runtime. I haven't been
successful so far, however, even after also reading most of the relevant
documentation.
The most simple representation (an oversimplification indeed) of what
I'm trying to accomplish is this:
class Base1:
pass
class Base2:
pass
class Meta:
pass
class Good(Meta):
pass
What I want to achieve at runtime is this:
g1 = Good(Base1) # a Good object with base class Base1
g2 = Good(Base2) # a Good object with base class Base2
Of course, this oversimplified (pseudo-code) example will not work but
illustrates most clearly my idea. How can I come closest to realizing
this by using the above mechanisms?
Thanks
--Henk
--