Re: Using class attributes

2010-02-18 Thread Leo Breebaart
Arnaud Delobelle writes: > > One observation: if I implement the descriptor solution as > > given above, the code works perfectly, but running the code > > through pychecker now causes an error, because that again > > causes an attempt to read from the non-existant base class > > template file "F

Re: Using class attributes

2010-02-18 Thread Arnaud Delobelle
Leo Breebaart writes: > Arnaud Delobelle writes: > >> Descriptors to the rescue :) >> >> def read_body_from(filename): >> print "** loading content **" >> return "" % filename >> >> # This is a kind of class property >> class TemplateFilename(object): >> def __get__(self, obj, cls)

Re: Using class attributes

2010-02-18 Thread Leo Breebaart
Arnaud Delobelle writes: > Descriptors to the rescue :) > > def read_body_from(filename): > print "** loading content **" > return "" % filename > > # This is a kind of class property > class TemplateFilename(object): > def __get__(self, obj, cls): > return "%s.tmpl" % cls._

Re: Using class attributes

2010-02-16 Thread Terry Reedy
On 2/16/2010 8:56 AM, Leo Breebaart wrote: Chris Rebert writes: On Mon, Feb 15, 2010 at 10:29 AM, Leo Breebaart wrote: I have a base class Foo with a number of derived classes FooA, FooB, FooC, etc. Each of these derived classes needs to read (upon initialisation) text from an associated te

Re: Using class attributes

2010-02-16 Thread Arnaud Delobelle
Jean-Michel Pichavant writes: [...] > While all these proposals are giving interesting technical anwsers to > the OP problem, I think that the OP original code is still the best > (_imo_). > > class Foo(object): > def __init__(self): > self.template_filename = "%s.tmpl" % self.__cla

Re: Using class attributes

2010-02-16 Thread Jean-Michel Pichavant
Arnaud Delobelle wrote: Leo Breebaart writes: Chris Rebert writes: On Mon, Feb 15, 2010 at 10:29 AM, Leo Breebaart wrote: I have a base class Foo with a number of derived classes FooA, FooB, FooC, etc. Each of these derived classes needs to read (upon initialisation) text

Re: Using class attributes

2010-02-16 Thread Arnaud Delobelle
Leo Breebaart writes: > Chris Rebert writes: > >> On Mon, Feb 15, 2010 at 10:29 AM, Leo Breebaart wrote: >> >> > I have a base class Foo with a number of derived classes FooA, >> > FooB, FooC, etc. Each of these derived classes needs to read >> > (upon initialisation) text from an associated te

Re: Using class attributes

2010-02-16 Thread Leo Breebaart
Chris Rebert writes: > On Mon, Feb 15, 2010 at 10:29 AM, Leo Breebaart wrote: > > > I have a base class Foo with a number of derived classes FooA, > > FooB, FooC, etc. Each of these derived classes needs to read > > (upon initialisation) text from an associated template file > > FooA.tmpl, FooB.

Re: Using class attributes

2010-02-15 Thread Chris Rebert
On Mon, Feb 15, 2010 at 10:29 AM, Leo Breebaart wrote: > I have a base class Foo with a number of derived classes FooA, > FooB, FooC, etc. Each of these derived classes needs to read > (upon initialisation) text from an associated template file > FooA.tmpl, FooB.tmpl, FooC.tmpl, etc. > > I can der

Using class attributes

2010-02-15 Thread Leo Breebaart
I have a base class Foo with a number of derived classes FooA, FooB, FooC, etc. Each of these derived classes needs to read (upon initialisation) text from an associated template file FooA.tmpl, FooB.tmpl, FooC.tmpl, etc. I can derive the template filename string for each instance by doing someth