A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2004-April/044164.html below:

[Python-Dev] Re: PEP 318: Decorators last before colon

[Python-Dev] Re: PEP 318: Decorators last before colon [Python-Dev] Re: PEP 318: Decorators last before colonMark Russell marktrussell at btopenworld.com
Thu Apr 8 19:51:24 EDT 2004
On Mon, 2004-04-05 at 19:03, Guido van Rossum wrote:
> > Would it not be possible to cheat and make the lexer transform 
> > 
> > 	"[" WHITESPACE "as" WHITESPACE IDENTIFIER 
> > 
> > into an LBRACE-AS token (which I assume would make the parser's job
> > simple).
> 
> I don't think without extreme hackery, but feel free to prove me wrong
> by producing a patch.  (A problem is, there could be newlines and
> comments inside the WHITESPACE.  Backtracking over that would require
> the lexer to have an arbitrary-length buffer.)

Unless I'm missing something (very possible) there's no need to
backtrack over the whitespace - all you need is a two-entry stack for
the "[" and the token that follows.  There's no question of INDENT or
DEDENT because we're inside a [] pair.  I've put a patch at
python.org/sf/932100 which does this, plus changes to Grammar/Grammar,
compile.c etc - it implements the syntax:

	[as classmethod]
	def foo(cls): pass

The newline is optional:

	[as foo, bar, baz] def foo(cls): pass

is also legal.

The test suite passes as before (there are still two failures but they
are unrelated to this patch).  The patch also includes your
test_decorators.py, modified for the new syntax.

Mark


More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4