ahh, this changes the inheritence for *all* instances of of the class, not
just this instance!  it seems like the '__class__' attribute is shared
across all instances of a specific class.. 

S

-----Original Message-----
From: Stefan Kuzminski [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 29, 2002 4:20 PM
To: 'Jeff Shannon'; [EMAIL PROTECTED]
Subject: RE: dynamic inheritence question


I found it, 

self.__class__.__bases__ 

so I dynamically inherit like this..

self.__class__.__bases__  = self.__class__.__bases__ + (Mixin,)

pretty nifty, this link helps..

http://starship.python.net/crew/gandalf/DNET/classes/DynamicObject.py.html

Stefan

-----Original Message-----
From: Jeff Shannon [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 29, 2002 11:04 AM
To: [EMAIL PROTECTED]
Subject: Re: dynamic inheritence question



David Ascher wrote:

> Stefan Kuzminski wrote:
> >
> > This is more a general python question, but does anyone know how to
modify
> > the inheritance of an object ( an actual instance of an object not the
class
> > definition ) at runtime?  i.e.  I have
> >
> > class A:
> >
> > and
> >
> > class B
> >
> > I go along happily..
> >
> > a = A()
> > b = B()
> >
> > now I want b inherit from a, using the objects just created above,  not
> > creating new ones..  I saw this done somewhere ( Webware maybe? ) but I
> > can't find it now.
>
> b.__class__ == A
>
> Simple =)

Wouldn't this make b an instance of class A, though, instead of inheriting
from
it?

I *think* (from vague memories) that what would need to be done for
inheritance
would be something like:

b.__bases__ == [ A ]

(though you might need to do that on the class B instead of the instance b
... )

Jeff Shannon
Technician/Programmer
Credit International


_______________________________________________
ActivePython mailing list
[EMAIL PROTECTED]
To unsubscribe:
http://listserv.ActiveState.com/mailman/listinfo/activepython
_______________________________________________
ActivePython mailing list
[EMAIL PROTECTED]
To unsubscribe:
http://listserv.ActiveState.com/mailman/listinfo/activepython
_______________________________________________
ActivePython mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/listinfo/activepython

Reply via email to