Re: dynamic inheritance

2006-06-21 Thread alf
Michele Simionato wrote: > alf wrote: > Python is ways cooler than C++. I switched to Python from C++ over year ago and do not see a way back. C++ just sucks at each corner. > This is a sensible use case where you may > want to change the base class at runtime: Thx for the example. A. -- htt

Re: dynamic inheritance

2006-06-21 Thread Michele Simionato
alf wrote: > I did not think about any particular problem, just thought it would be > cool to abstract out the base class. In fact you can do that in C++ (to > some extend) using templates and parameterizing the base class. Python is ways cooler than C++. This is a sensible use case where you may

Re: dynamic inheritance

2006-06-20 Thread alf
bruno at modulix wrote: > > *But* you'd probably better tell us about the problem you're trying to > solve. Since in Python, inheritance is mostly about implementation (ie: > not needed for subtyping), your problem would probably be best solved > with composition/delegation, for which Python offe

Re: dynamic inheritance

2006-06-09 Thread bruno at modulix
alf wrote: > is there any way to tell the class the base class during runtime? > Technically, yes - the solution depending on your definition of "during runtime" FWIW, the class statement is evaled at import/load time, which is "during runtime" So if you want to use one or other (compatible)

Re: dynamic inheritance

2006-06-09 Thread Kay Schluehr
alf wrote: > is there any way to tell the class the base class during runtime? > > a. Example: >>> class A(object):pass >>> class B(A):pass >>> B.mro() [, , ] See also Micheles nice article about the semantics of the "mro" ( method resolution order). http://www.python.org/download/releases/2.3

Re: dynamic inheritance

2006-06-08 Thread Dan Sommers
On Thu, 08 Jun 2006 21:14:48 -0400, alf <[EMAIL PROTECTED]> wrote: > is there any way to tell the class the base class during runtime? >>> class A(object): >>> pass >>> class B(object): >>> pass >>> o = A() >>> o.__class__ >>> o.__class__ = B >>> o.__c

dynamic inheritance

2006-06-08 Thread alf
is there any way to tell the class the base class during runtime? a. -- http://mail.python.org/mailman/listinfo/python-list