A decorator syntax not yet mentioned (I think!)

Carl Banks imbosol at aerojockey.com
Wed Aug 11 22:46:49 EDT 2004


steven.bethard at gmail.com (Steven Bethard) wrote in message news:<d11dcfba.0408111433.43f025f8 at posting.google.com>...

> I know there were complaints before about this sort of indentation,
> but I couldn't find them in python-dev and the comments in the wiki
> don't discuss this in any detail.  Can anyone tell me why this
> indentation syntax was dispreferred?  Specifically, I'm interested in
> why this is so drastically different from the other paired blocks:
> if/elif/else, try/except, try/finally, etc. 

One thing that's different is that, in all those cases, the second
block has a keyword that can't appear alone.  You can't have an except
without a try, or an else without an if, but you could have a def
without a decorate.

For that reason, I suggest it would be a bit more congruent (not
necessarily enough to justify another new keyword) with the rest of
Python to also use a keyword different from def, say ddef.

    decorate:
        ...
    ddef function(args):
        ...

Either is definitely very passable if we must go the before-the-def
route.


> Also, there's a comment
> in the wiki that says that there are technical problems with the
> grammar if a block *starts* with an optional part.  Does this not
> apply to the @ case (which also starts a block with an optional part)?

It doesn't seem like there would be a problem defining it in, for
example, yacc.  def and decorate...def could be two different
statements.



More information about the Python-list mailing list