Author farcat
Recipients farcat, glchapman, lorph, mwh
Date 2009-04-21.09:13:21
SpamBayes Score 1.17004e-09
Marked as misclassified No
Message-id <1240305204.03.0.59118555223.issue672115@psf.upfronthosting.co.za>
In-reply-to
Content
in my project i need to be able to let the user dynamically make and
remove inheritance relationships between classes and in my testing i
think i have run into this issue assigning to __bases__. the

class object(object):
    pass

trick seems to work, but i can't really oversee the consequenses. I also
saw another variation which might be the same issue:

    A= type("A", (object,), {'one': 1})
    B= type("B", (object,), {'two': 2})
    C= type("C", (object,), {'three': 3})

    A = type("A",(A,B),{})
    
    print dir(A)
    print A.__bases__
    print '-----------------------------------'
    A.__bases__ = (B,C)
    print dir(A)
    print A.__bases__
    print '-----------------------------------'

no exceptions, but the second dir(A) shows that A has lost its attribute
'one'

if the class object(object) trick is not safe, is there a way to get the
dynamic inheritance behaviour in another way, e.g. through metaclasses?
History
Date User Action Args
2009-04-21 09:13:24farcatsetrecipients: + farcat, mwh, glchapman, lorph
2009-04-21 09:13:24farcatsetmessageid: <1240305204.03.0.59118555223.issue672115@psf.upfronthosting.co.za>
2009-04-21 09:13:22farcatlinkissue672115 messages
2009-04-21 09:13:22farcatcreate