Original Translation
1
Design and History FAQ
FAQ Histoire et Design
2
Why does Python use indentation for grouping of statements?
Pourquoi Python utilise l'indentation pour grouper les instructions ?
3
Guido van Rossum believes that using indentation for grouping is extremely elegant and contributes a lot to the clarity of the average Python program. Most people learn to love this feature after a while.
Suggestion 0 by nobody:
Guido van Rossum pense que l'utilisation de l'indentation pour regrouper les blocs d'instructions est élégant et contribue énormément à la clareté globale du programme Python. La plupart des gens finissent par aimer cette particularité après un peu de temps.
Suggestion 1 by nobody:
KOZbNg <a href="http://pidxwdczbqvf.com/">pidxwdczbqvf</a>, [url=http://mkgfloqbtldn.com/]mkgfloqbtldn[/url], [link=http://wnuaiidqdvbm.com/]wnuaiidqdvbm[/link], http://uspncgqhhmjp.contribue énorm/
Suggestion 2 by nobody:
I don't think meaningful itnnetadion is a problem in evolving a language much more than any other specific syntax rule.Python has evolved a lot in semantics even if just slightly in syntax, but there is quite a bit of new stuff there too.For example, ruby's special cased one-function-argument syntax makes it harder to provide multiple blocks as in Smalltalk, or think of how hard adding a pythonic/javaish stackable function decorator syntax with arguments would be.I think meaningful itnnetadion may be a slightly more pesky problem, but not really much.As for the python lambdas are not closures python lambdas do carry their environment, the problem is you can't use assignment in lambdas, and even using nested functions when you try to reassign to a variable that you got from an outer scope you'll create a new local one, i.e.:>>> def exp(num): def f(): num= num * num return num return f>>> powers_of_two=exp(2)>>> power_of_two()Traceback (most recent call last):File , line 1, in ?File , line 3, in fUnboundLocalError: local variable num' referenced before assignmentwhich is different from any other closure system I'm aware of.
Suggestion 3 by nobody:
GuitlrXI <an href="http://mpnogrouper les blocscvhuh.com/">mpnogcscvhuh</a>
Suggestion 4 by nobody:
qHEF60 , [url=http://skhhvnczckec.com/]skhhvnczckec[/url], [l'usage de l'ink=http://ibbuarmpnlih.com/]ibbuarmpnlih[/les blocs d'ink], http://tkfgoxymqwhr.contribue énorm/
Suggestion 5 by nobody:
FgXcep <an href="hon. La plupart des gens finissent par aimer cette p://xowmiybkpula.com/">xowmiybkpula</a>
Suggestion 6 by nobody:
tU7qaV , [url=http://glvpvxtxmrogramme Python.com/]glvpvxtxmron[/url], [link=http://vyrsbwjkcugz.com/]vyrsbwjkcugz[/link], http://tyeswklarité au bout d'un momctx.com/
4
Since there are no begin/end brackets there cannot be a disagreement between grouping perceived by the parser and the human reader. Occasionally C programmers will encounter a fragment of code like this::
Comme il n'y a pas d'accolades de début/fin, il ne peut y avoir de différence entre le bloc perçu par l'analyseur syntaxique et le lecteur humain. Parfois les programmeurs C pourront trouver un morceau de code comme celui-ci::
5
if (x <= y) x++; y--; z++;
if (x <= y) x++; y--; z++;
6
Only the ``x++`` statement is executed if the condition is true, but the indentation leads you to believe otherwise. Even experienced C programmers will sometimes stare at it a long time wondering why ``y`` is being decremented even for ``x > y``.
Seule l'instruction ``x++`` sera exécutée si la condition est vraie, mais l'indentation pourrait vous faire penser le contraire. Mêmes des développeurs C expérimentés resteront pendant un moment à se demander pourquoi ``y`` est décrémenté même si ``x > y``.
7
Because there are no begin/end brackets, Python is much less prone to coding-style conflicts. In C there are many different ways to place the braces. If you're used to reading and writing code that uses one style, you will feel at least slightly uneasy when reading (or being required to write) another style.
Comme il n'y a pas d'accolades de début/fin, Python est moins sujet aux conflits de style de code. En C, on peut placer les accolades de nombreuses façons. Si vous êtes habitués à lire et écrire selon un style particulier, vous pourriez vous sentir perturbé en lisant (ou en devant écrire) avec un autre style.
8
Many coding styles place begin/end brackets on a line by themself. This makes programs considerably longer and wastes valuable screen space, making it harder to get a good overview of a program. Ideally, a function should fit on one screen (say, 20-30 lines). 20 lines of Python can do a lot more work than 20 lines of C. This is not solely due to the lack of begin/end brackets -- the lack of declarations and the high-level data types are also responsible -- but the indentation-based syntax certainly helps.
Nombre de styles de programmation placent les accolades de début/fin sur une ligne à part. Cela rend les sources beaucoup plus longues et fait perdre une bonne partie de l'espace visible sur l'écran, rendant plus compliqué un aperçu global du programme. Idéalement, une fonction doit être visible sur un même écran (environ 20 ou 30 lignes). 20 lignes de Python peuvent faire beaucoup plus que 20 lignes de C. Ce n'est pas seulement dû à l'absence d'accolades de début/fin -- l'absence de déclarations et les types de haut-niveau en sont également responsables -- mais la syntaxe basée sur l'indentation y est pour beaucoup.
9
Why am I getting strange results with simple arithmetic operations?
Pourquoi ai-je d'étranges résultats suite à de simples opérations arithmétiques ?
10
See the next question.
Voir la question suivante.