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
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)
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._
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
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
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
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
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.
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
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
10 matches
Mail list logo