On Tue, 21 Aug 2012 17:47:28 +1000, Nick Coghlan <ncogh...@gmail.com> wrote: > On Tue, Aug 21, 2012 at 11:55 AM, Ezio Melotti <ezio.melo...@gmail.com> wrote: > >> +String literals that are part of a single expression and have only > >> whitespace > >> +between them will be implicitly converted to a single string literal. > >> + > > > > > > Is it a string /literal/ they are converted to? > Yup: > > >>> ast.dump(compile('"hello world"', '', 'eval', flags=ast.PyCF_ONLY_AST)) > "Expression(body=Str(s='hello world'))" > >>> ast.dump(compile('"hello" " world"', '', 'eval', flags=ast.PyCF_ONLY_AST)) > "Expression(body=Str(s='hello world'))" > > > Anyway a simple ('foo' 'bar') == 'foobar' example might make this sentence > > more understandable. > > Added.
I think it is an important and subtle point that this happens at "compile time" rather than "run time". Subtle in that it is not at all obvious (as this question demonstrates), and important in that it does have performance implications (even if those are trivial in most cases). So I think it would be worth saying "implicitly converted to a single string literal when the source is parsed", or something like that. --David _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com