Showing content from http://mail.python.org/pipermail/python-dev/attachments/20150908/112ec767/attachment.html below:
<div dir="ltr">Sounds awfully premature. Style guides are typically updated in response to the occurrence of bad practice in the wild, not in anticipation of such bad practice. I would give the users of Python 3.6 some more credit.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 8, 2015 at 12:17 AM, Mike Miller <span dir="ltr"><<a href="mailto:python-dev@mgmiller.net" target="_blank">python-dev@mgmiller.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I'd like to collect thinking on best practices that we can use as a style guide for string interpolation. Now that arbitrary expressions are very likely to be included, it is more important to set guidelines than it would otherwise be.<br>
<br>
Below is a recent post with some good ideas (though it hopes to restrict expressions, which is not what we're discussing here, but rather creation of a style-guide for code-review a la PEP8).<br>
<br>
Would anyone else like to contribute?<br>
<br>
-Mike<br>
<br>
Recent posts:<br>
<br>
- On PEPs to augment PEP8:<br>
<br>
  <a href="https://mail.python.org/pipermail/python-dev/2015-September/141473.html" rel="noreferrer" target="_blank">https://mail.python.org/pipermail/python-dev/2015-September/141473.html</a><br>
<br>
- On things to avoid in f-strings:<br>
<br>
  <a href="https://mail.python.org/pipermail/python-dev/2015-September/141451.html" rel="noreferrer" target="_blank">https://mail.python.org/pipermail/python-dev/2015-September/141451.html</a><br>
  (part included below)<br>
<br>
<br>
On 09/05/2015 02:10 AM, haypo s (Victor Stinner) wrote:<br>
> Would it be possible to specify a subset of the Python language<br>
> allowed in f-string? For example, __import__ or lambda should not be<br>
> used in a f-string. I'm not convinced that a loop or<br>
> list/dict/set-comprehension is a good idea neither.<br>
><br>
> I would prefer to keep as much code as possible *outside* f-string because:<br>
> - text editor knows well how to color it<br>
> - static analyzers know how to analyze it<br>
> - it encourage developers to indent and comment their code correctly,<br>
> whereas f-string has more restrictons on indentation (is it possible<br>
> to indent and comment code inside a f-string?)<br>
><br>
> For example, for me it's a common practice to write a complex<br>
> list-comprehension on two lines for readability:<br>
><br>
> newlist = [very_complex_expression(item)<br>
>Â Â Â Â Â Â Â for item in oldlist]<br>
> # sorry, it's hard to indent correctly in a mail client, especially Gmail<br>
><br>
> Well, I'm not convinced that we need a larger subset than what is<br>
> allowed currently in str.format(), simple expressions like: obj.attr,<br>
> obj[index], etc.<br>
><br>
> I recall horrible examples in the previous mail threads showing how<br>
> much complex code you can put inside f-string.<br>
><br>
> Even the following example from the PEP seems too complex to me:<br>
> print(f"Usage: {sys.argv[0]} [{'|'.join('--'+opt for opt in<br>
> valid_opts)}]", file=sys.stderr)<br>
><br>
> Oh, first I read [...] as a list-comprehension :-p But it's part of<br>
> the output string, not of the Python code...<br>
><br>
> I prefer to build the second parameter outside the f-string:<br>
> opts = '|'.join('--'+opt for opt in valid_opts)<br>
> print(f"Usage: {sys.argv[0]} [{opts}]", file=sys.stderr)<br>
><br>
_______________________________________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org" target="_blank">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/guido%40python.org" rel="noreferrer" target="_blank">https://mail.python.org/mailman/options/python-dev/guido%40python.org</a><br>
</blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div>
</div>
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