Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7ae90dd

Browse files
committed
Elaborate encoding recommendations, and fix ambiguous wording for list comprehensions.
1 parent 1b8b718 commit 7ae90dd

2 files changed

Lines changed: 13 additions & 9 deletions

File tree

Doc/tutorial/controlflow.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,12 @@ extracted for you:
675675
(see :ref:`tut-firstclasses` for more on classes and methods).
676676

677677
* Don't use fancy encodings if your code is meant to be used in international
678-
environments. Plain ASCII works best in any case.
678+
environments. Python's default, UTF-8, or even plain ASCII work best in any
679+
case.
680+
681+
* Likewise, don't use non-ASCII characters in identifiers if there is only the
682+
slightest chance people speaking a different language will read or maintain
683+
the code.
679684

680685

681686
.. rubric:: Footnotes

Doc/tutorial/datastructures.rst

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,11 @@ Common applications are to make lists where each element is the result of
162162
some operations applied to each member of the sequence, or to create a
163163
subsequence of those elements that satisfy a certain condition.
164164

165-
166-
Each list comprehension consists of an expression followed by a :keyword:`for`
167-
clause, then zero or more :keyword:`for` or :keyword:`if` clauses. The result
168-
will be a list resulting from evaluating the expression in the context of the
169-
:keyword:`for` and :keyword:`if` clauses which follow it. If the expression
170-
would evaluate to a tuple, it must be parenthesized.
165+
A list comprehension consists of brackets containing an expression followed
166+
by a :keyword:`for` clause, then zero or more :keyword:`for` or :keyword:`if`
167+
clauses. The result will be a list resulting from evaluating the expression in
168+
the context of the :keyword:`for` and :keyword:`if` clauses which follow it. If
169+
the expression would evaluate to a tuple, it must be parenthesized.
171170

172171
Here we take a list of numbers and return a list of three times each number::
173172

@@ -348,8 +347,8 @@ The reverse operation is also possible::
348347
>>> x, y, z = t
349348

350349
This is called, appropriately enough, *sequence unpacking* and works for any
351-
sequence on the right-hand side. Sequence unpacking requires the list of
352-
variables on the left to have the same number of elements as the length of the
350+
sequence on the right-hand side. Sequence unpacking requires that there are as
351+
many variables on the left side of the equals sign as there are elements in the
353352
sequence. Note that multiple assignment is really just a combination of tuple
354353
packing and sequence unpacking.
355354

0 commit comments

Comments
 (0)