Gabriel Genellina wrote:

>      def __call__(self, *args, **kwds):
>         return self.__TemplateMethod(*args, **kwds)
>
> x = Template()(prefix="foo")
> or perhaps:
> x = Template(prefix="foo")()
>
> I think the extra () improves readability - it's clear that x comes from a
> function call, it's not a Template instance as one would expect from your
> original code.
> And depending on the application, you could keep the instances and call
> them with different arguments - with the original code you always create a
> new instance just to discard it immediately.
>
> --
Thanks for the reply. I was considering __call__ but in my case it is
really something
that will be discarded immediately. And right now it is is implemented
as function
where I have arguments to send in which customize functions something
like:
def Template(self, func1=Customize1, func2= Customize2, *args,
**kwds):
    func1(*args, **kwds)
    func2(*args, **kwds)

So I just wanted to organize it a little bit nicer and be able to
subclass instead of
sending in function pointers. But that had the same interface.

But you are right the extra () does make it clearer, so I probably go
for that.

Cheers,

/T

> Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to