Original Translation
34
Many people used to C or Perl complain that they want to use this C idiom:
De nombreuses personnes habituées à C ou Perl se plaignent de vouloir utiliser cet idiome C :
35
while (line = readline(f)) { // do something with line }
while (line = readline(f)) { // faire quelque chose avec line }
36
where in Python you're forced to write this::
où en Python vous êtes forcé à écrire ceci ::
37
while True: line = f.readline() if not line: break ... # do something with line
while True: line = f.readline() if not line: break ... # faire quelque chose avec line
38
The reason for not allowing assignment in Python expressions is a common, hard-to-find bug in those other languages, caused by this construct:
La raison pour ne pas autoriser l'assignation dans les expressions en Python est un bug fréquent, et difficile à trouver dans ces autres langages, causé par cette construction :
39
if (x = 0) { // error handling } else { // code that only works for nonzero x }
40
The error is a simple typo: ``x = 0``, which assigns 0 to the variable ``x``, was written while the comparison ``x == 0`` is certainly what was intended.
Cette erreur est une simple coquille : ``x = 0``, qui assigne 0 à la variable ``x``, a été écrit alors que la comparaison ``x == 0`` est certainement ce qui était souhaité.
41
Many alternatives have been proposed. Most are hacks that save some typing but use arbitrary or cryptic syntax or keywords, and fail the simple criterion for language change proposals: it should intuitively suggest the proper meaning to a human reader who has not yet been introduced to the construct.
De nombreuses alternatives ont été proposées. La plupart des hacks économisaient de la frappe mais utilisaient d'arbitraires ou cryptiques syntaxes ou mot-clés et faillait le simple critère pour proposition de changement du langage : ça doit intuitivement suggérer la bonne signification au lecteur qui n'a pas encore été introduit à la construction.
42
An interesting phenomenon is that most experienced Python programmers recognize the ``while True`` idiom and don't seem to be missing the assignment in expression construct much; it's only newcomers who express a strong desire to add this to the language.
Un phénomène intéressant est que la plupart des programmeurs Python expérimentés reconnaissent l'idiome ``while True`` et ne semblent pas manquer l'assignation dans la construction de l'expression; seuls les nouveaux-venus expriment un fort désir d'ajouter ceci au langage.
43
There's an alternative way of spelling this that seems attractive but is generally less robust than the "while True" solution::
Il y a une manière alternative de faire ça qui semble attrayante mais elle est généralement moins robuste que la solution ``while True`` ::