[Pythonmac-SIG] changging inheritance on the fly?

altern enrike at altern.org
Sun Apr 17 21:16:26 CEST 2005


Michael Hudson wrote:
> altern <enrike at altern.org> writes:
> 
> 
>>hi
>>
>>probably a bit offtopic since it is nothing mac specific but i didnt
>>know where to ask.
> 
> 
> python-list?
> 
> 
>>is it possible to change the superclass a class inherits from on the fly?
> 
> 
> You can assign to __bases__.
> 
> 
>>for example i have this class inheriting from Top but i want it to
>>inherit later on the fly from another class living in another
>>module. I am doing this below but it doesnt work, 'm' doesnt
>>change. Maybe i have to define the class Test on the fly to achive
>>this? but i dont like much to do that. any other suggestions? thanks
>>
>>#this is what i am doing now:
>>
>>import mymodule as m
>>
>>def start():
>>	import othermodule as m
>>	
>>class Test(m.Top):
>>	def __init__(self):
>>		pass
> 
> 
> The way you ask the question suggests you don't know Python especially
> well.  As Bob says, there are likely better ways to acheive your goal.

any tips about those other ways? i am reading pattern design books tring 
to find some way to do what i need, i know there must be some way but i 
am not a computer programmer myself, i keep learning...
thanks!

> Cheers,
> mwh
> 


-- 
enrike


More information about the Pythonmac-SIG mailing list