On Sun, Mar 22, 2015 at 2:49 PM, Thomas 'PointedEars' Lahn
<pointede...@web.de> wrote:
>> Implicit concatenation is part of the syntax, not part of the expression
>> evaluator.
>
> Reads like nonsense to me.

What do you mean? String concatenation by abuttal is as much a
syntactic element as the distinction between regular, raw, and
triple-quoted string literals. By the time you get to AST (never mind
about byte code), that information is gone:

>>> print(ast.dump(ast.parse("""
... x = '''hello'''
... """)))
Module(body=[Assign(targets=[Name(id='x', ctx=Store())], value=Str(s='hello'))])
>>> print(ast.dump(ast.parse("""
... x = r'hello'
... """)))
Module(body=[Assign(targets=[Name(id='x', ctx=Store())], value=Str(s='hello'))])
>>> print(ast.dump(ast.parse("""
... x = "hello"
... """)))
Module(body=[Assign(targets=[Name(id='x', ctx=Store())], value=Str(s='hello'))])
>>> print(ast.dump(ast.parse("""
... x = "he" "ll" "o"
... """)))
Module(body=[Assign(targets=[Name(id='x', ctx=Store())], value=Str(s='hello'))])

Nothing in the expression evaluator knows or cares about what kind of
string literal you used, nor whether you included more than one. It's
all just alternative forms of string literal.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to