Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: pages/coding-style.html

Issue 29345361: Noissue - Update Python coding practices for string literals (Closed)
Patch Set: Don't mention Python 3 Created May 30, 2016, 1:28 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pages/coding-style.html
===================================================================
--- a/pages/coding-style.html
+++ b/pages/coding-style.html
@@ -45,7 +45,7 @@
<ul>
<li>{{python-general Follow <a href="https://www.python.org/dev/peps/pep-0008/">PEP-8</a> and the recommendations in the offical Python documentation.}}</li>
<li>{{python-version Make the code compatible with both Python 2.7 and Python 3.5+ (see <a href="https://docs.python.org/dev/howto/pyporting.html">this guide</a>). Use <a href="https://docs.python.org/2/library/__future__.html">__future__ imports</a> to address syntactic differences but avoid <a href="https://pythonhosted.org/six/">six</a>, <a href="http://python-future.org/compatible_idioms.html">python-future</a>, etc. to not introduce additional dependencies.}}</li>
- <li>{{python-strings Write string literals so that they match the behaviour of <a href="https://docs.python.org/2/library/functions.html#func-repr"><code><fix>repr()</fix></code></a> in Python 2, or <a href="https://docs.python.org/3/library/functions.html#ascii"><code><fix>ascii()</fix></code></a> in Python 3, i.e. use single quotes except to avoid escaping of embedded quotes and escape special and non-ascii characters. For docstrings, however, follow <a href="https://www.python.org/dev/peps/pep-0257/">PEP-257</a>.}}</li>
+ <li>{{python-strings Write string literals so that they match the behaviour of <a href="https://docs.python.org/3/library/functions.html#ascii"><code><fix>ascii()</fix></code></a>, i.e. use single quotes except to avoid escaping of embedded quotes and use <code><fix>\u</fix></code> escapes for non-ascii characters but don't prefix strings with <code><fix>u</fix></code>. For docstrings, however, follow <a href="https://www.python.org/dev/peps/pep-0257/">PEP-257</a>.}}</li>
<li>{{python-prefix In modules, prefix private functions and variables with a single underscore.}}</li>
<li>{{python-concatenation Use the <code><fix>+</fix></code> operator when concatenating exactly two strings, use the <a href="https://docs.python.org/2/library/stdtypes.html#str.format"><code><fix>format()</fix></code> method</a> for more complex string formatting, use the <a href="https://docs.python.org/2/library/stdtypes.html#str.join"><code><fix>join()</fix></code> method</a> when concatenating pre-existing sequences.}}</li>
<li>{{python-tuple-vs-list Use tuples for data that have structure, use lists for data that have order.}}</li>
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld