mixing statements into J2

Anthony Baxter anthonybaxter at gmail.com
Fri Aug 27 05:54:37 CEST 2004


On Thu, 26 Aug 2004 10:36:08 -0700, Robert Brewer <fumanchu at amor.org> wrote:
> > > The order of operation would have to be reversed,
> >
> > I don't see why.
> 
> It's not a requirement, but it seems reasonable to me. If you're going
> to set off a decorator suite and then mix in normal Python statements,
> the two models collide over order of operation:
> 
> using:
>     if test:
>         memoize
>     else:
>         synchronize
>     classmethod
> def foo(self, *args):
>     stuff(args)

Ah - see, you've _also_ included statements in the decorator block.
This is not going to be allowed - the decorators _must_ be
expressions. This example code is actually a pretty strong "anti"
point for J2 that I hadn't been able to quite articulate before - it
_looks_ like a normal block, but it isn't. Only expressions can be in
it.
The above _should_ generate a SyntaxError on the 'if'.



More information about the Python-list mailing list