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/2012-August/121407.html below:

revamp the sequence docs in order to better explain the state of

[Python-Dev] [Python-checkins] cpython: Close #4966: revamp the sequence docs in order to better explain the state ofR. David Murray rdmurray at bitdance.com
Tue Aug 21 14:01:15 CEST 2012
On Tue, 21 Aug 2012 17:47:28 +1000, Nick Coghlan <ncoghlan at gmail.com> wrote:
> On Tue, Aug 21, 2012 at 11:55 AM, Ezio Melotti <ezio.melotti at 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
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