[Python-ideas] Syntax: 'return: ...' expressions

Nick Coghlan ncoghlan at gmail.com
Tue Jan 6 16:25:39 CET 2015


On 6 January 2015 at 11:59, Yawar Amin <yawar.amin at gmail.com> wrote:
> On 2015-01-05 04:49, Andrew Barnert wrote:
>> ... paren continuation just concatenates the lines together.
>
> I'll quote this first, because it's the crux of the matter and what I
> failed to understand up until now. IIUC now, Python never actually
> 'relaxes' any indentation rules--a preprocessor just concatenates split
> lines (i.e. lines split with parens etc.) and then passes the result on
> to the parser?

Not quite. INDENT, DEDENT and NEWLINE are possible tokens generated by
the tokeniser. They're only generated to delimit statements, never
inside expressions - by the time the parser itself gets involved, the
original whitespace has been elided by the tokenisation process.

> It's back to the drawing board for me, I guess :-)

You may find http://python-notes.curiousefficiency.org/en/latest/pep_ideas/suite_expr.html
an interesting read.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-ideas mailing list