[Tutor] Dynamic inheritance?

Jan Eden lists at janeden.org
Sat Nov 19 22:15:46 CET 2005

Hi Kent,

Kent Johnson wrote on 19.11.2005:

>Jan Eden wrote:

>> Is there a way to dynamically determine the value of Super at
>> runtime? Background: Depending on certain object attributes which are
>> set during the object initialization, I need to use a different set
>> of templates for the respective object.
>Sure, just import the correct template module conditionally and give it a new 
>if site == 'siteA':
>  import SiteA as Super
>  import SiteB as Super
>class A(Super.A):
>If you need to do the import based on a string use the __import__() function:
Excellent. This is exactly what I need. I was not aware of the fact that you can rename modules upon importing them.

>> The problem is that the template classes are not self contained, i.e.
>> SiteB.Gallery inherits from SiteB.List, SiteB.Base etc.> 
>> Thanks in advance,
>I don't see why that is a problem?
Please disregard the last statement in my first message: There is indeed no problem with this requirement.

Thanks for your help,

Common sense is what tells you that the world is flat.

More information about the Tutor mailing list