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 >name: > >if site == 'siteA': > import SiteA as Super >else > import SiteB as Super > >class A(Super.A): > >etc. > >If you need to do the import based on a string use the __import__() function: >http://www.python.org/doc/current/lib/built-in-funcs.html > 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, Jan -- Common sense is what tells you that the world is flat. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor