On Sep 25, 1:51 pm, apoirier <
alain.poiri...@gmail.com> wrote:
> Hi Brannon,
>
> This annotation is called a "decorator". The short answer is that
>
> @presentation.render_for(Counter1)
> def render(self, h, comp, *args):
> ...
>
> is syntaxic sugar for:
>
> def render(self, h, comp, *args):
> ...
> render = presentation.render_for(Counter1)(render)
I've looked at a few tutorials on Decorators, but
1 - none of them use method call notation in them, such as your
presentation.render_for
2 - The sequence of parenthetical expressions confuses me ....
"""(Counter1)(render)"""
is that parsed as:
tmp = presentation.render_for(Counter1)
render = presentation.tmp(render)
But I have the basic idea. The function render is being 'wrapped' such
that some other things take the core function as an argument then
produce a version of render that cooperates with the calling
conventions of the framework.
It's being used to keep the Model free of View code