[Python-Dev] Dropping decorator syntax for 2.4?

Guido van Rossum guido at python.org
Fri Jun 4 10:17:27 EDT 2004

> I don't recall Guido's patch.  Did he modify the grammar or can it
> all be done inside the compiler?

The parser generator is too weak to allow a grammar change to work, so
I did it in the compiler.

> Not that it's practical for 2.4, but I
> think it wouldn't be hard to post-process the existing AST to
> recognize decorators written like this.
> You'd like for adjacent statements of the form:
>     Expr(List())
>     FunctionDef()
> and replace them with a single
>     FunctionDef()
> Or do we need to catch Expr(ListComp()) too?  PEP 318 doesn't mention
> semantics anywhere, so it doesn't say what is allowed inside the
> square brackets.

My patch excludes list comprehensions, because I need to know the
number of elements of the list for the code I generate.  The PEP
should be disambiguated to disallow list comps.

(I see no merit to the import hook + bytecode hack approach.)

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-Dev mailing list