Re: [Tutor] Dynamic inheritance?

2005-11-23 Thread Kent Johnson
Jan Eden wrote: > Jan Eden wrote on 22.11.2005: >>Kent Johnson wrote on 20.11.2005: >> >>>Use getattr() to access attributes by name. SiteA is an attribute >>>of Templates and Page is an attribute of SiteA so you can get use >>>getattr() twice to get what you want: >>> >>>site = getattr(Templates,

Re: [Tutor] Dynamic inheritance?

2005-11-22 Thread Jan Eden
Hi, Jan Eden wrote on 22.11.2005: >Hi, > >Kent Johnson wrote on 20.11.2005: >> >>Use getattr() to access attributes by name. SiteA is an attribute >>of Templates and Page is an attribute of SiteA so you can get use >>getattr() twice to get what you want: >> >>site = getattr(Templates, self.site_n

Re: [Tutor] Dynamic inheritance?

2005-11-22 Thread Jan Eden
Hi, Kent Johnson wrote on 20.11.2005: > >Use getattr() to access attributes by name. SiteA is an attribute of >Templates and Page is an attribute of SiteA so you can get use >getattr() twice to get what you want: > >site = getattr(Templates, self.site_name) self.template = >getattr(site, self.temp

Re: [Tutor] Dynamic inheritance?

2005-11-20 Thread Alan Gauld
> import Templates > > self.site_name = 'SiteA' > self.template_type = 'Page' > > self.template = ??? How about a dictionary holding references to the classes against their names? The dictionary could be a class attribute of the top level superclass or a module level dictionary. It should be upd

Re: [Tutor] Dynamic inheritance?

2005-11-20 Thread Jan Eden
Kent Johnson wrote on 20.11.2005: >Use getattr() to access attributes by name. SiteA is an attribute of Templates >and Page is an attribute of SiteA so you can get use getattr() twice to get >what >you want: > >site = getattr(Templates, self.site_name) >self.template = getattr(site, self.templa

Re: [Tutor] Dynamic inheritance?

2005-11-20 Thread Kent Johnson
Jan Eden wrote: > The situation is this: > > For every object, two string attributes are determined during > initialization (one being read from a database, the other inherited > as a superclass attribute). The first contains the site name, the > second the object type. I'd like to set the templat

Re: [Tutor] Dynamic inheritance?

2005-11-19 Thread Jan Eden
Kent Johnson wrote on 19.11.2005: >Danny Yoo wrote: >>Here's a small example that shows how classes can be treated just >>like any other value in Python: >> >> # >> def makeYa(superclass): >> class Ya(superclass): >> def sayHi(self): >>

Re: [Tutor] Dynamic inheritance?

2005-11-19 Thread Kent Johnson
Danny Yoo wrote: > Here's a small example that shows how classes can be treated just like any > other value in Python: > > # > def makeYa(superclass): > class Ya(superclass): > def sayHi(self): > superclass.sayHi(self) > p

Re: [Tutor] Dynamic inheritance?

2005-11-19 Thread Python
On Sat, 2005-11-19 at 15:23 -0800, Danny Yoo wrote: > Here's a small example that shows how classes can be treated just like any > other value in Python: > > # > def makeYa(superclass): > class Ya(superclass): > def sayHi(self): > su

Re: [Tutor] Dynamic inheritance?

2005-11-19 Thread Danny Yoo
On Sat, 19 Nov 2005, Jan Eden wrote: > I have a number of classes, each of which should inherit from a related > superclass in another module: > > class A(Super.A): > ... > > class B(Super.B): > ... > > class C(Super.C): > ... > > Is there a way to dynamically determine the value of

Re: [Tutor] Dynamic inheritance?

2005-11-19 Thread Jan Eden
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 res

Re: [Tutor] Dynamic inheritance?

2005-11-19 Thread Kent Johnson
Jan Eden wrote: > Hi, > > I have a number of classes, each of which should inherit from a > related superclass in another module: > > class A(Super.A): ... > > class B(Super.B): ... > > class C(Super.C): ... > > Is there a way to dynamically determine the value of Super at > runtime? Backgroun

Re: [Tutor] Dynamic inheritance?

2005-11-19 Thread Python
On Sat, 2005-11-19 at 16:45 +0100, 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 ob

[Tutor] Dynamic inheritance?

2005-11-19 Thread Jan Eden
Hi, I have a number of classes, each of which should inherit from a related superclass in another module: class A(Super.A): ... class B(Super.B): ... class C(Super.C): ... Is there a way to dynamically determine the value of Super at runtime? Background: Depending on certain obje