forked from AFPy/python-docs-fr
804 lines
37 KiB
Plaintext
804 lines
37 KiB
Plaintext
# SOME DESCRIPTIVE TITLE.
|
|
# Copyright (C) 1990-2016, Python Software Foundation
|
|
# This file is distributed under the same license as the Python package.
|
|
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
|
#
|
|
#, fuzzy
|
|
msgid ""
|
|
msgstr ""
|
|
"Project-Id-Version: Python 2.7\n"
|
|
"Report-Msgid-Bugs-To: \n"
|
|
"POT-Creation-Date: 2016-10-30 10:44+0100\n"
|
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
|
"MIME-Version: 1.0\n"
|
|
"Content-Type: text/plain; charset=UTF-8\n"
|
|
"Content-Transfer-Encoding: 8bit\n"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:5
|
|
msgid "An Informal Introduction to Python"
|
|
msgstr "Introduction informelle à Python"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:7
|
|
msgid ""
|
|
"In the following examples, input and output are distinguished by the "
|
|
"presence or absence of prompts (:term:`>>>` and :term:`...`): to repeat the "
|
|
"example, you must type everything after the prompt, when the prompt appears; "
|
|
"lines that do not begin with a prompt are output from the interpreter. Note "
|
|
"that a secondary prompt on a line by itself in an example means you must "
|
|
"type a blank line; this is used to end a multi-line command."
|
|
msgstr ""
|
|
"Dans les exemples qui suivent, les entrées et sorties se distinguent par la "
|
|
"présence ou l'absence d'invite (:term:`>>>` et :term:`...`) : pour "
|
|
"reproduire les exemples, vous devez taper tout ce qui est après l'invite, au "
|
|
"moment où celle-ci apparaît ; les lignes qui n'affichent pas d'invite sont "
|
|
"les sorties de l'interpréteur. Notez qu'une invite secondaire affichée seule "
|
|
"sur une ligne dans un exemple indique que vous devez entrer une ligne vide ; "
|
|
"ceci est utilisé pour terminer une commande multi-lignes."
|
|
|
|
#: ../Doc/tutorial/introduction.rst:14
|
|
msgid ""
|
|
"Many of the examples in this manual, even those entered at the interactive "
|
|
"prompt, include comments. Comments in Python start with the hash character, "
|
|
"``#``, and extend to the end of the physical line. A comment may appear at "
|
|
"the start of a line or following whitespace or code, but not within a string "
|
|
"literal. A hash character within a string literal is just a hash character. "
|
|
"Since comments are to clarify code and are not interpreted by Python, they "
|
|
"may be omitted when typing in examples."
|
|
msgstr ""
|
|
"Beaucoup d'exemples de ce manuel, même ceux saisis à l'invite de "
|
|
"l'interpréteur, incluent des commentaires. Les commentaires en Python "
|
|
"commencent avec un caractère dièse, ``#``, et s'étendent jusqu'à la fin de "
|
|
"la ligne. Un commentaire peut apparaître au début d'une ligne ou à la suite "
|
|
"d'un espace ou de code, mais pas à l'intérieur d'une chaîne de caractères "
|
|
"littérale. Un caractère dièse à l'intérieur d'une chaîne de caractères est "
|
|
"juste un caractère dièse. Comme les commentaires ne servent qu'à expliquer "
|
|
"le code et ne sont pas interprétés par Python, ils peuvent être ignorés "
|
|
"lorsque vous tapez les exemples."
|
|
|
|
#: ../Doc/tutorial/introduction.rst:22
|
|
msgid "Some examples::"
|
|
msgstr "Quelques exemples : ::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:33
|
|
msgid "Using Python as a Calculator"
|
|
msgstr "Utiliser Python comme une calculatrice"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:35
|
|
msgid ""
|
|
"Let's try some simple Python commands. Start the interpreter and wait for "
|
|
"the primary prompt, ``>>>``. (It shouldn't take long.)"
|
|
msgstr ""
|
|
"Essayons quelques commandes Python simples. Démarrez l'interpréteur et "
|
|
"attendez l'invite primaire, ``>>>``. Ça ne devrait pas être long."
|
|
|
|
#: ../Doc/tutorial/introduction.rst:42
|
|
msgid "Numbers"
|
|
msgstr "Les nombres"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:44
|
|
msgid ""
|
|
"The interpreter acts as a simple calculator: you can type an expression at "
|
|
"it and it will write the value. Expression syntax is straightforward: the "
|
|
"operators ``+``, ``-``, ``*`` and ``/`` work just like in most other "
|
|
"languages (for example, Pascal or C); parentheses (``()``) can be used for "
|
|
"grouping. For example::"
|
|
msgstr ""
|
|
"L'interpréteur agit comme une simple calculatrice : vous pouvez lui entrer "
|
|
"une expression et il vous affiche la valeur. La syntaxe des expressions est "
|
|
"simple : les opérateurs ``+``, ``-``, ``*`` et ``/`` fonctionnent comme dans "
|
|
"la plupart des langages (par exemple, Pascal ou C) ; les parenthèses peuvent "
|
|
"être utilisées pour faire des regroupements. Par exemple : ::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:59
|
|
msgid ""
|
|
"The integer numbers (e.g. ``2``, ``4``, ``20``) have type :class:`int`, the "
|
|
"ones with a fractional part (e.g. ``5.0``, ``1.6``) have type :class:"
|
|
"`float`. We will see more about numeric types later in the tutorial."
|
|
msgstr ""
|
|
"Les nombre entiers (comme ``2``, ``4``, ``20``) sont de type :class:`int`, "
|
|
"alors que les décimaux (comme ``5.0``, ``1.6``) sont de type :class:`float`. "
|
|
"Plus de détails sont données sur les types numériques plus loin dans ce "
|
|
"tutoriel."
|
|
|
|
#: ../Doc/tutorial/introduction.rst:63
|
|
msgid ""
|
|
"The return type of a division (``/``) operation depends on its operands. If "
|
|
"both operands are of type :class:`int`, :term:`floor division` is performed "
|
|
"and an :class:`int` is returned. If either operand is a :class:`float`, "
|
|
"classic division is performed and a :class:`float` is returned. The ``//`` "
|
|
"operator is also provided for doing floor division no matter what the "
|
|
"operands are. The remainder can be calculated with the ``%`` operator::"
|
|
msgstr ""
|
|
"Le type donné en résultat d'une division (``/``) dépend de ses opérandes. Si "
|
|
"les deux opérandes sont de type :class:`int`, c'est une :term:`division "
|
|
"entière` qui est effectuée, et un :class:`int` et donné. Si l'une des "
|
|
"opérandes est un :class:`float`, une division classique est effectuée et un :"
|
|
"class:`float` est renvoyé. L'opérateur ``//`` permet quand à lui d'effectuer "
|
|
"des division entières peu importe ses opérandes. Le reste de la division est "
|
|
"calculé grâce à l'opérateur ``%`` ::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:81
|
|
msgid ""
|
|
"With Python, it is possible to use the ``**`` operator to calculate powers "
|
|
"[#]_::"
|
|
msgstr ""
|
|
"Avec Python il est possible de calculer des puissances avec l'opérateur "
|
|
"``**`` [#]_ ::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:88
|
|
msgid ""
|
|
"The equal sign (``=``) is used to assign a value to a variable. Afterwards, "
|
|
"no result is displayed before the next interactive prompt::"
|
|
msgstr ""
|
|
"Le signe égal (``=``) est utilisé pour affecter une valeur à une variable. "
|
|
"Après cela, aucun résultat n'est affiché avant l'invite suivante : ::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:96
|
|
msgid ""
|
|
"If a variable is not \"defined\" (assigned a value), trying to use it will "
|
|
"give you an error::"
|
|
msgstr ""
|
|
"Si une variable n'est pas \"définie\" (si aucune valeur ne lui a été "
|
|
"affecté), l'utiliser engendrera une erreur : ::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:104
|
|
msgid ""
|
|
"There is full support for floating point; operators with mixed type operands "
|
|
"convert the integer operand to floating point::"
|
|
msgstr ""
|
|
"Il y a un support complet des nombres à virgule flottante ; les opérateurs "
|
|
"avec des types d'opérandes mélangés convertissent l'opérande entier en "
|
|
"virgule flottante : ::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:112
|
|
msgid ""
|
|
"In interactive mode, the last printed expression is assigned to the variable "
|
|
"``_``. This means that when you are using Python as a desk calculator, it "
|
|
"is somewhat easier to continue calculations, for example::"
|
|
msgstr ""
|
|
"En mode interactif, la dernière expression affichée est affectée à la "
|
|
"variable ``_``. Ce qui signifie que lorsque vous utilisez Python comme "
|
|
"calculatrice, il est parfois plus simple de continuer des calculs, par "
|
|
"exemple : ::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:125
|
|
msgid ""
|
|
"This variable should be treated as read-only by the user. Don't explicitly "
|
|
"assign a value to it --- you would create an independent local variable with "
|
|
"the same name masking the built-in variable with its magic behavior."
|
|
msgstr ""
|
|
"Cette variable doit être considérée comme une variable en lecture seule par "
|
|
"l'utilisateur. Ne lui affectez pas de valeur explicitement --- vous créeriez "
|
|
"ainsi une variable locale indépendante avec le même nom qui masquerait la "
|
|
"variable native et son fonctionnement magique."
|
|
|
|
#: ../Doc/tutorial/introduction.rst:129
|
|
msgid ""
|
|
"In addition to :class:`int` and :class:`float`, Python supports other types "
|
|
"of numbers, such as :class:`~decimal.Decimal` and :class:`~fractions."
|
|
"Fraction`. Python also has built-in support for :ref:`complex numbers "
|
|
"<typesnumeric>`, and uses the ``j`` or ``J`` suffix to indicate the "
|
|
"imaginary part (e.g. ``3+5j``)."
|
|
msgstr ""
|
|
"En plus des :class:`int` et des :class:`float`, il existe les :class:"
|
|
"`~decimal.Decimal` et les :class:`~fractions.Fraction`. Python gère aussi "
|
|
"les :ref:`nombre complexes <typesnumeric>`, en utilisant le suffixe ``j`` ou "
|
|
"``J`` pour indiquer la partie imaginaire (tel que: ``3+5j``)."
|
|
|
|
#: ../Doc/tutorial/introduction.rst:139
|
|
msgid "Strings"
|
|
msgstr "Les chaînes de caractères"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:141
|
|
msgid ""
|
|
"Besides numbers, Python can also manipulate strings, which can be expressed "
|
|
"in several ways. They can be enclosed in single quotes (``'...'``) or "
|
|
"double quotes (``\"...\"``) with the same result [#]_. ``\\`` can be used "
|
|
"to escape quotes::"
|
|
msgstr ""
|
|
"Au delà des nombres, Python peut aussi manipuler des chaînes de caractères, "
|
|
"qui peuvent être exprimés de différentes manières. Elles peuvent être "
|
|
"écrites entre guillemets simples (``'...'``) ou entre guillemets (``\"..."
|
|
"\"``) sans distinction [#]_. ``\\`` peut être utilisé pour protéger un "
|
|
"guillemet : ::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:159
|
|
msgid ""
|
|
"In the interactive interpreter, the output string is enclosed in quotes and "
|
|
"special characters are escaped with backslashes. While this might sometimes "
|
|
"look different from the input (the enclosing quotes could change), the two "
|
|
"strings are equivalent. The string is enclosed in double quotes if the "
|
|
"string contains a single quote and no double quotes, otherwise it is "
|
|
"enclosed in single quotes. The :keyword:`print` statement produces a more "
|
|
"readable output, by omitting the enclosing quotes and by printing escaped "
|
|
"and special characters::"
|
|
msgstr ""
|
|
|
|
#: ../Doc/tutorial/introduction.rst:179
|
|
msgid ""
|
|
"If you don't want characters prefaced by ``\\`` to be interpreted as special "
|
|
"characters, you can use *raw strings* by adding an ``r`` before the first "
|
|
"quote::"
|
|
msgstr ""
|
|
"Pour éviter que les caractères précédées d'un ``\\`` ne soient interprétés "
|
|
"comme étant spéciaux, utilisez les *chaînes brutes* (*raw strings*) en "
|
|
"préfixant la chaîne d'un ``r`` ::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:189
|
|
msgid ""
|
|
"String literals can span multiple lines. One way is using triple-quotes: ``"
|
|
"\"\"\"...\"\"\"`` or ``'''...'''``. End of lines are automatically included "
|
|
"in the string, but it's possible to prevent this by adding a ``\\`` at the "
|
|
"end of the line. The following example::"
|
|
msgstr ""
|
|
"Les chaînes de caractères peuvent s'étendre sur plusieurs lignes. On peut "
|
|
"utiliser les triples guillemets, simples ou doubles: ``'''...'''`` ou ``"
|
|
"\"\"\"...\"\"\"``. Les retours à la ligne sont automatiquement inclus, mais "
|
|
"on peut l'en empêcher en ajoutant ``\\`` à la fin de la ligne. L'exemple "
|
|
"suivant : ::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:200
|
|
msgid ""
|
|
"produces the following output (note that the initial newline is not "
|
|
"included):"
|
|
msgstr ""
|
|
"produit l'affichage suivant (notez que le premier retour à la ligne n'est "
|
|
"pas inclus) :"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:208
|
|
msgid ""
|
|
"Strings can be concatenated (glued together) with the ``+`` operator, and "
|
|
"repeated with ``*``::"
|
|
msgstr ""
|
|
"Les chaines peuvent être concaténées (collées ensemble) avec l'opérateur ``"
|
|
"+``, et répétées avec l'opérateur ``*``::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:215
|
|
msgid ""
|
|
"Two or more *string literals* (i.e. the ones enclosed between quotes) next "
|
|
"to each other are automatically concatenated. ::"
|
|
msgstr ""
|
|
"Plusieurs chaînes de caractères, écrites littéralement (c'est à dire entre "
|
|
"guillemets), côte à côte, sont automatiquement concaténées. ::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:221
|
|
msgid ""
|
|
"This only works with two literals though, not with variables or expressions::"
|
|
msgstr ""
|
|
"Cela ne fonctionne cependant qu'avec les chaînes littérales, pas les "
|
|
"variables ni les expressions : ::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:231
|
|
msgid ""
|
|
"If you want to concatenate variables or a variable and a literal, use ``+``::"
|
|
msgstr ""
|
|
"Pour concaténer des variables, ou des variables avec des chaînes littérales, "
|
|
"utilisez l'opérateur ``+``::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:236
|
|
msgid ""
|
|
"This feature is particularly useful when you want to break long strings::"
|
|
msgstr ""
|
|
"Cette fonctionnalité est surtout intéressante pour couper des chaînes trop "
|
|
"longues : ::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:243
|
|
msgid ""
|
|
"Strings can be *indexed* (subscripted), with the first character having "
|
|
"index 0. There is no separate character type; a character is simply a string "
|
|
"of size one::"
|
|
msgstr ""
|
|
"Les chaînes de caractères peuvent être indexées (accéder aux caractères par "
|
|
"leur position), le premiercaractère d'une chaîne est à la position 0. Il "
|
|
"n'existe pas de type distinct pour les caractères, un caractère est "
|
|
"simplement une chaîne de longueur 1 ::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:253
|
|
msgid ""
|
|
"Indices may also be negative numbers, to start counting from the right::"
|
|
msgstr ""
|
|
"Les indices peuvent également être négatifs, pour effectuer un décompte en "
|
|
"partant de la droite. Par exemple : ::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:262
|
|
msgid "Note that since -0 is the same as 0, negative indices start from -1."
|
|
msgstr "Notez que puisque -0 égal 0, les indices négatifs commencent par -1."
|
|
|
|
#: ../Doc/tutorial/introduction.rst:264
|
|
msgid ""
|
|
"In addition to indexing, *slicing* is also supported. While indexing is "
|
|
"used to obtain individual characters, *slicing* allows you to obtain a "
|
|
"substring::"
|
|
msgstr ""
|
|
|
|
#: ../Doc/tutorial/introduction.rst:272
|
|
msgid ""
|
|
"Note how the start is always included, and the end always excluded. This "
|
|
"makes sure that ``s[:i] + s[i:]`` is always equal to ``s``::"
|
|
msgstr ""
|
|
"Notez que le début est toujours inclus et la fin toujours exclue. Cela "
|
|
"assure que ``s[:i] + s[i:]`` est toujours égal à ``s`` ::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:280
|
|
msgid ""
|
|
"Slice indices have useful defaults; an omitted first index defaults to zero, "
|
|
"an omitted second index defaults to the size of the string being sliced. ::"
|
|
msgstr ""
|
|
"Les indices par tranches ont des valeurs par défaut utiles ; le premier "
|
|
"indice lorsqu'il est omis équivaut à zéro, le second à la taille de la "
|
|
"chaîne de caractères : ::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:290
|
|
msgid ""
|
|
"One way to remember how slices work is to think of the indices as pointing "
|
|
"*between* characters, with the left edge of the first character numbered 0. "
|
|
"Then the right edge of the last character of a string of *n* characters has "
|
|
"index *n*, for example::"
|
|
msgstr ""
|
|
"Une façon de mémoriser la façon dont les tranches fonctionnent est de penser "
|
|
"que les indices pointent *entre* les caractères, le côté gauche du premier "
|
|
"caractère ayant la position 0. Le côté droit du dernier caractère d'une "
|
|
"chaîne de *n* caractères a alors pour indice *n*, par exemple : ::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:301
|
|
msgid ""
|
|
"The first row of numbers gives the position of the indices 0...6 in the "
|
|
"string; the second row gives the corresponding negative indices. The slice "
|
|
"from *i* to *j* consists of all characters between the edges labeled *i* and "
|
|
"*j*, respectively."
|
|
msgstr ""
|
|
"La première ligne de nombres donne la position des indices 0...6 dans la "
|
|
"chaîne ; la deuxième ligne donne l'indice négatif correspondant. La tranche "
|
|
"de *i* à *j* est constituée de tous les caractères situés entre les bords "
|
|
"libellés *i* et *j*, respectivement."
|
|
|
|
#: ../Doc/tutorial/introduction.rst:306
|
|
msgid ""
|
|
"For non-negative indices, the length of a slice is the difference of the "
|
|
"indices, if both are within bounds. For example, the length of "
|
|
"``word[1:3]`` is 2."
|
|
msgstr ""
|
|
"Pour des indices non négatifs, la longueur d'une tranche est la différence "
|
|
"entre ces indices, si les deux sont entre les bornes. Par exemple, la longue "
|
|
"de ``word[1:3]`` est 2."
|
|
|
|
#: ../Doc/tutorial/introduction.rst:310
|
|
msgid "Attempting to use an index that is too large will result in an error::"
|
|
msgstr "Utiliser un indice trop grand générera une erreur : ::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:317
|
|
msgid ""
|
|
"However, out of range slice indexes are handled gracefully when used for "
|
|
"slicing::"
|
|
msgstr ""
|
|
"Cependant, les indices hors bornes sont gérés silencieusement lorsqu'ils "
|
|
"sont utilisés dans des tranches : ::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:325
|
|
msgid ""
|
|
"Python strings cannot be changed --- they are :term:`immutable`. Therefore, "
|
|
"assigning to an indexed position in the string results in an error::"
|
|
msgstr ""
|
|
"Les chaînes de caractères, en Python ne peuvent pas être modifiées, on dit "
|
|
"quelles sont :term:`immutable`. Affecter une nouvelle valeur à un indice "
|
|
"dans une chaîne produit une erreur : ::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:335
|
|
msgid "If you need a different string, you should create a new one::"
|
|
msgstr ""
|
|
"Si vous avez besoin d'une chaîne différente, vous devez en créer une "
|
|
"autre : ::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:342
|
|
msgid "The built-in function :func:`len` returns the length of a string::"
|
|
msgstr "La fonction native :func:`len` renvoie la longueur d'une chaîne : ::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:354
|
|
msgid ":ref:`typesseq`"
|
|
msgstr ""
|
|
|
|
#: ../Doc/tutorial/introduction.rst:352
|
|
msgid ""
|
|
"Strings, and the Unicode strings described in the next section, are examples "
|
|
"of *sequence types*, and support the common operations supported by such "
|
|
"types."
|
|
msgstr ""
|
|
"Les chaînes de caractères, et les chaînes Unicode décrites dans la prochaine "
|
|
"section, sont des exemples de *types de séquences*, et supportent donc les "
|
|
"opérations classiques prises en charge par ces types."
|
|
|
|
#: ../Doc/tutorial/introduction.rst:358
|
|
msgid ":ref:`string-methods`"
|
|
msgstr ":ref:`string-methods`"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:357
|
|
msgid ""
|
|
"Both strings and Unicode strings support a large number of methods for basic "
|
|
"transformations and searching."
|
|
msgstr ""
|
|
"Aussi bien les chaînes de caractères que les chaînes Unicode supportent un "
|
|
"large éventail de méthodes de transformations basiques et de recherche."
|
|
|
|
#: ../Doc/tutorial/introduction.rst:361
|
|
msgid ":ref:`formatstrings`"
|
|
msgstr ":ref:`formatstrings`"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:361
|
|
msgid "Information about string formatting with :meth:`str.format`."
|
|
msgstr ""
|
|
"Informations sur le formatage des chaînes avec la méthode :meth:`str.format`."
|
|
|
|
#: ../Doc/tutorial/introduction.rst:364
|
|
msgid ":ref:`string-formatting`"
|
|
msgstr ":ref:`string-formatting`"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:364
|
|
msgid ""
|
|
"The old formatting operations invoked when strings and Unicode strings are "
|
|
"the left operand of the ``%`` operator are described in more detail here."
|
|
msgstr ""
|
|
"Les anciennes opérations de formatage appelées lorsque les chaînes de "
|
|
"caractères et les chaînes Unicode sont les opérandes placés à gauche de "
|
|
"l'opérateur ``%`` sont décrites plus en détail ici."
|
|
|
|
#: ../Doc/tutorial/introduction.rst:371
|
|
msgid "Unicode Strings"
|
|
msgstr "Chaînes Unicode"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:376
|
|
msgid ""
|
|
"Starting with Python 2.0 a new data type for storing text data is available "
|
|
"to the programmer: the Unicode object. It can be used to store and "
|
|
"manipulate Unicode data (see http://www.unicode.org/) and integrates well "
|
|
"with the existing string objects, providing auto-conversions where necessary."
|
|
msgstr ""
|
|
"À partir de Python 2.0, un nouveau type permettant de stocker du texte est "
|
|
"mis à la disposition du programmeur : le type Unicode. Il peut être utilisé "
|
|
"pour stocker et manipuler des données Unicode (voir http://www.unicode.org/) "
|
|
"et s'intègre très bien avec les types de chaînes de caractères existant, en "
|
|
"fournissant une conversion automatique lorsque c'est nécessaire."
|
|
|
|
#: ../Doc/tutorial/introduction.rst:381
|
|
msgid ""
|
|
"Unicode has the advantage of providing one ordinal for every character in "
|
|
"every script used in modern and ancient texts. Previously, there were only "
|
|
"256 possible ordinals for script characters. Texts were typically bound to a "
|
|
"code page which mapped the ordinals to script characters. This lead to very "
|
|
"much confusion especially with respect to internationalization (usually "
|
|
"written as ``i18n`` --- ``'i'`` + 18 characters + ``'n'``) of software. "
|
|
"Unicode solves these problems by defining one code page for all scripts."
|
|
msgstr ""
|
|
"Unicode a l'avantage de fournir une valeur ordinale pour chaque caractère "
|
|
"d'un script utilisé aussi bien dans d'anciens textes que dans des textes "
|
|
"modernes. Auparavant, il n'y avait que 256 valeurs ordinales possibles pour "
|
|
"chaque caractère. Chaque texte était typiquement associé à une page de codes "
|
|
"qui associait une valeur ordinale à chaque caractère. Ceci conduisait à une "
|
|
"grande confusion, notamment pour tout ce qui touchait à "
|
|
"l'internationalisation (souvent écrite ``i18n`` --- ``'i'`` + 18 caractères "
|
|
"+ ``'n'``) des logiciels. Unicode résout ces problèmes en définissant une "
|
|
"page de code unique pour tous les scripts."
|
|
|
|
#: ../Doc/tutorial/introduction.rst:389
|
|
msgid ""
|
|
"Creating Unicode strings in Python is just as simple as creating normal "
|
|
"strings::"
|
|
msgstr ""
|
|
"Créer des chaînes Unicode en Python est aussi simple que de créer des "
|
|
"chaînes de caractères normales ::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:395
|
|
msgid ""
|
|
"The small ``'u'`` in front of the quote indicates that a Unicode string is "
|
|
"supposed to be created. If you want to include special characters in the "
|
|
"string, you can do so by using the Python *Unicode-Escape* encoding. The "
|
|
"following example shows how::"
|
|
msgstr ""
|
|
"Le petit ``'u'`` qui précède l'apostrophe indique que l'on veut créer une "
|
|
"chaîne Unicode. Si vous voulez intégrer des caractères spéciaux dans la "
|
|
"chaîne, vous pouvez le faire en utilisant l'encodage Python d'échappement "
|
|
"des caractères Unicode. Comme dans cet exemple ::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:403
|
|
msgid ""
|
|
"The escape sequence ``\\u0020`` indicates to insert the Unicode character "
|
|
"with the ordinal value 0x0020 (the space character) at the given position."
|
|
msgstr ""
|
|
"La séquence d'échappement ``\\u0020`` indique d'insérer le caractère Unicode "
|
|
"de valeur ordinale 0x0020 (un espace) à la position indiquée."
|
|
|
|
#: ../Doc/tutorial/introduction.rst:406
|
|
msgid ""
|
|
"Other characters are interpreted by using their respective ordinal values "
|
|
"directly as Unicode ordinals. If you have literal strings in the standard "
|
|
"Latin-1 encoding that is used in many Western countries, you will find it "
|
|
"convenient that the lower 256 characters of Unicode are the same as the 256 "
|
|
"characters of Latin-1."
|
|
msgstr ""
|
|
"Les autres caractères sont interprétés en utilisant leurs valeurs ordinales "
|
|
"respectives directement comme des ordinaux Unicode. Si vous avez des chaînes "
|
|
"littérales dans l'encodage standard Latin-1 utilisé dans de nombreux pays "
|
|
"occidentaux, vous trouverez pratique que les 256 premiers caractères Unicode "
|
|
"soient les mêmes que ceux de l'encodage Latin-1."
|
|
|
|
#: ../Doc/tutorial/introduction.rst:412
|
|
msgid ""
|
|
"For experts, there is also a raw mode just like the one for normal strings. "
|
|
"You have to prefix the opening quote with 'ur' to have Python use the *Raw-"
|
|
"Unicode-Escape* encoding. It will only apply the above ``\\uXXXX`` "
|
|
"conversion if there is an uneven number of backslashes in front of the small "
|
|
"'u'. ::"
|
|
msgstr ""
|
|
"Pour les experts, il existe également un mode \"brut\" identique à celui "
|
|
"disponible pour les chaînes de caractères. Vous devez préfixer la première "
|
|
"apostrophe avec 'ur' pour que Python utilise l'encodage *Unicode-Brut*. Il "
|
|
"n'appliquera la conversion ``\\uXXXX`` de l'exemple ci-dessous que s'il y a "
|
|
"un nombre impair d'antislashs devant le petit 'u' ::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:423
|
|
msgid ""
|
|
"The raw mode is most useful when you have to enter lots of backslashes, as "
|
|
"can be necessary in regular expressions."
|
|
msgstr ""
|
|
"Le mode brut est le plus utile lorsque vous devez saisir de nombreux "
|
|
"antislashs, comme il peut être nécessaire de le faire dans des expressions "
|
|
"rationnelles."
|
|
|
|
#: ../Doc/tutorial/introduction.rst:426
|
|
msgid ""
|
|
"Apart from these standard encodings, Python provides a whole set of other "
|
|
"ways of creating Unicode strings on the basis of a known encoding."
|
|
msgstr ""
|
|
"En dehors de ces encodages standards, Python fournit d'autres méthodes pour "
|
|
"créer des chaînes Unicode sur la base d'un encodage connu."
|
|
|
|
#: ../Doc/tutorial/introduction.rst:431
|
|
msgid ""
|
|
"The built-in function :func:`unicode` provides access to all registered "
|
|
"Unicode codecs (COders and DECoders). Some of the more well known encodings "
|
|
"which these codecs can convert are *Latin-1*, *ASCII*, *UTF-8*, and "
|
|
"*UTF-16*. The latter two are variable-length encodings that store each "
|
|
"Unicode character in one or more bytes. The default encoding is normally set "
|
|
"to ASCII, which passes through characters in the range 0 to 127 and rejects "
|
|
"any other characters with an error. When a Unicode string is printed, "
|
|
"written to a file, or converted with :func:`str`, conversion takes place "
|
|
"using this default encoding. ::"
|
|
msgstr ""
|
|
"La primitive :func:`unicode` donne accès à tous les codecs (COdeurs et "
|
|
"DECodeurs) enregistrés. Certains des encodages les plus connus pris en "
|
|
"charge par ces codecs sont *Latin-1*, *ASCII*, *UTF-8* et *UTF-16*. Les deux "
|
|
"derniers sont des encodages à longueur variable qui stockent chaque "
|
|
"caractère Unicode dans un ou plusieurs octets. L'encodage par défaut est "
|
|
"normalement défini en ASCII, qui gère les caractères de valeur ordinale 0 à "
|
|
"127 et rejette tous les autres caractères avec une erreur. Quand une chaîne "
|
|
"Unicode est imprimée, écrite dans un fichier ou convertie avec la fonction :"
|
|
"func:`str`, une conversion s'effectue en utilisant cet encodage par défaut ::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:451
|
|
msgid ""
|
|
"To convert a Unicode string into an 8-bit string using a specific encoding, "
|
|
"Unicode objects provide an :func:`encode` method that takes one argument, "
|
|
"the name of the encoding. Lowercase names for encodings are preferred. ::"
|
|
msgstr ""
|
|
"Pour convertir une chaîne Unicode en une chaîne encodée sur 8 bits en "
|
|
"utilisant un encodage spécifique, les objets Unicode fournissent une "
|
|
"méthode :func:`encode` qui prend pour argument le nom de l'encodage. Les "
|
|
"noms d'encodages en minuscules sont préférés ::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:458
|
|
msgid ""
|
|
"If you have data in a specific encoding and want to produce a corresponding "
|
|
"Unicode string from it, you can use the :func:`unicode` function with the "
|
|
"encoding name as the second argument. ::"
|
|
msgstr ""
|
|
"Si vous avez une donnée dans un encodage spécifique et voulez générer la "
|
|
"chaîne Unicode correspondante, vous pouvez utiliser la fonction :func:"
|
|
"`unicode` en fournissant le nom de l'encodage comme second argument ::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:469
|
|
msgid "Lists"
|
|
msgstr "Les listes"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:471
|
|
msgid ""
|
|
"Python knows a number of *compound* data types, used to group together other "
|
|
"values. The most versatile is the *list*, which can be written as a list of "
|
|
"comma-separated values (items) between square brackets. Lists might contain "
|
|
"items of different types, but usually the items all have the same type. ::"
|
|
msgstr ""
|
|
"Python connaît différents types de données *combinés*, utilisés pour "
|
|
"regrouper plusieurs valeurs. La plus souple est la *liste*, qui peut être "
|
|
"écrite comme une suite de valeurs (éléments) séparés par des virgules placée "
|
|
"entre crochets. Les éléments d'une liste ne sont pas obligatoirement tous du "
|
|
"même type, bien qu'à l'usage ce soit souvent le cas. ::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:480
|
|
msgid ""
|
|
"Like strings (and all other built-in :term:`sequence` type), lists can be "
|
|
"indexed and sliced::"
|
|
msgstr ""
|
|
"Comme les chaînes de caractères (et toute autre types de :term:`sequence`), "
|
|
"les listes peuvent être indicées et découpées : ::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:490
|
|
msgid ""
|
|
"All slice operations return a new list containing the requested elements. "
|
|
"This means that the following slice returns a new (shallow) copy of the "
|
|
"list::"
|
|
msgstr ""
|
|
"Toutes les opérations par tranches renvoient une nouvelle liste contenant "
|
|
"les éléments demandés. Ce qui signifie que l'opération suivante renvoie une "
|
|
"copie superficielle de la liste : ::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:496
|
|
msgid "Lists also supports operations like concatenation::"
|
|
msgstr ""
|
|
|
|
#: ../Doc/tutorial/introduction.rst:501
|
|
msgid ""
|
|
"Unlike strings, which are :term:`immutable`, lists are a :term:`mutable` "
|
|
"type, i.e. it is possible to change their content::"
|
|
msgstr ""
|
|
"Mais à la différence des listes qui sont :term:`immuable`\\s, les listes "
|
|
"sont :term:`mutable`\\s : il est possible de changer leur contenu : ::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:511
|
|
msgid ""
|
|
"You can also add new items at the end of the list, by using the :meth:`~list."
|
|
"append` *method* (we will see more about methods later)::"
|
|
msgstr ""
|
|
"Il est aussi possible d'ajouter de nouveaux éléments à la fin d'une liste "
|
|
"avec la méthode :meth:`~list.append`. (Les méthodes seront abordées plus "
|
|
"tard) ::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:519
|
|
msgid ""
|
|
"Assignment to slices is also possible, and this can even change the size of "
|
|
"the list or clear it entirely::"
|
|
msgstr ""
|
|
"Des affectations de tranches sont également possibles, ce qui peut même "
|
|
"modifier la taille de la liste ou la vider complètement : ::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:538
|
|
msgid "The built-in function :func:`len` also applies to lists::"
|
|
msgstr "La primitive :func:`len` s'applique aussi aux listes : ::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:544
|
|
msgid ""
|
|
"It is possible to nest lists (create lists containing other lists), for "
|
|
"example::"
|
|
msgstr ""
|
|
"Il est possible d'imbriquer des listes (de créer des listes contenant "
|
|
"d'autres listes), par exemple : ::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:560
|
|
msgid "First Steps Towards Programming"
|
|
msgstr "Premiers pas vers la programmation"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:562
|
|
msgid ""
|
|
"Of course, we can use Python for more complicated tasks than adding two and "
|
|
"two together. For instance, we can write an initial sub-sequence of the "
|
|
"*Fibonacci* series as follows::"
|
|
msgstr ""
|
|
"Bien entendu, on peut utiliser Python pour des tâches plus compliquées que "
|
|
"d'additionner deux et deux. Par exemple, on peut écrire une sous-séquence "
|
|
"initiale de la suite de Fibonacci comme ceci : ::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:580
|
|
msgid "This example introduces several new features."
|
|
msgstr "Cet exemple introduit plusieurs nouvelles fonctionnalités."
|
|
|
|
#: ../Doc/tutorial/introduction.rst:582
|
|
msgid ""
|
|
"The first line contains a *multiple assignment*: the variables ``a`` and "
|
|
"``b`` simultaneously get the new values 0 and 1. On the last line this is "
|
|
"used again, demonstrating that the expressions on the right-hand side are "
|
|
"all evaluated first before any of the assignments take place. The right-"
|
|
"hand side expressions are evaluated from the left to the right."
|
|
msgstr ""
|
|
"La première ligne contient une *affectation multiple* : les variables ``a`` "
|
|
"et ``b`` se voient affecter simultanément leurs nouvelles valeurs 0 et 1. "
|
|
"Cette méthode est encore utilisée à la dernière ligne, pour démontrer que "
|
|
"les expressions sur la partie droite de l'affectation sont toutes évaluées "
|
|
"avant que les affectations ne soient effectuées. Ces expressions en partie "
|
|
"droite sont toujours évaluées de la gauche vers la droite."
|
|
|
|
#: ../Doc/tutorial/introduction.rst:588
|
|
msgid ""
|
|
"The :keyword:`while` loop executes as long as the condition (here: ``b < "
|
|
"10``) remains true. In Python, like in C, any non-zero integer value is "
|
|
"true; zero is false. The condition may also be a string or list value, in "
|
|
"fact any sequence; anything with a non-zero length is true, empty sequences "
|
|
"are false. The test used in the example is a simple comparison. The "
|
|
"standard comparison operators are written the same as in C: ``<`` (less "
|
|
"than), ``>`` (greater than), ``==`` (equal to), ``<=`` (less than or equal "
|
|
"to), ``>=`` (greater than or equal to) and ``!=`` (not equal to)."
|
|
msgstr ""
|
|
"La boucle :keyword:`while` s'exécute tant que la condition (ici : ``b < "
|
|
"10``) reste vraie. En Python, comme en C, tout entier différent de zéro est "
|
|
"vrai et zéro est faux. La condition peut aussi être une chaîne de "
|
|
"caractères, une liste, ou en fait toute séquence ; une séquence avec une "
|
|
"valeur non nulle est vraie, une séquence vide est fausse. Le test utilisé "
|
|
"dans l'exemple est une simple comparaison. Les opérateurs de comparaison "
|
|
"standards sont écrits comme en C : ``<`` (inférieur), ``>`` (supérieur), "
|
|
"``==`` (égal), ``<=`` (inférieur ou égal), ``>=`` (supérieur ou égal) et ``!"
|
|
"=`` (non égal)."
|
|
|
|
#: ../Doc/tutorial/introduction.rst:597
|
|
msgid ""
|
|
"The *body* of the loop is *indented*: indentation is Python's way of "
|
|
"grouping statements. At the interactive prompt, you have to type a tab or "
|
|
"space(s) for each indented line. In practice you will prepare more "
|
|
"complicated input for Python with a text editor; all decent text editors "
|
|
"have an auto-indent facility. When a compound statement is entered "
|
|
"interactively, it must be followed by a blank line to indicate completion "
|
|
"(since the parser cannot guess when you have typed the last line). Note "
|
|
"that each line within a basic block must be indented by the same amount."
|
|
msgstr ""
|
|
"Le *corps* de la boucle est *indenté* : l'indentation est la méthode "
|
|
"utilisée par Python pour regrouper des instructions. En mode interactif, "
|
|
"vous devez saisir une tabulation ou des espaces pour chaque ligne indentée. "
|
|
"En pratique, vous aurez intérêt à utiliser un éditeur de texte pour les "
|
|
"saisies plus compliquées ; tous les éditeurs de texte dignes de ce nom "
|
|
"disposent d'une fonction d'auto-indentation. Lorsqu'une expression composée "
|
|
"est saisie en mode interactif, elle doit être suivie d'une ligne vide pour "
|
|
"indiquer qu'elle est terminée (car l'analyseur ne peut pas deviner que vous "
|
|
"venez de saisir la dernière ligne). Notez bien que toutes les lignes à "
|
|
"l'intérieur d'un bloc doivent être indentées au même niveau."
|
|
|
|
#: ../Doc/tutorial/introduction.rst:606
|
|
msgid ""
|
|
"The :keyword:`print` statement writes the value of the expression(s) it is "
|
|
"given. It differs from just writing the expression you want to write (as we "
|
|
"did earlier in the calculator examples) in the way it handles multiple "
|
|
"expressions and strings. Strings are printed without quotes, and a space is "
|
|
"inserted between items, so you can format things nicely, like this::"
|
|
msgstr ""
|
|
"L'instruction :keyword:`print` écrit la valeur de l'expression qui lui est "
|
|
"fournie. Ce n'est pas la même chose que d'écrire l'expression que vous "
|
|
"voulez écrire (comme nous l'avons fait dans l'exemple de la calculatrice), "
|
|
"et diffère dans la façon dont elle gère les expressions et chaînes de "
|
|
"caractères multiples. Les chaînes sont imprimées sans apostrophes et un "
|
|
"espace est inséré entre les éléments de telle sorte que vous pouvez "
|
|
"facilement formater les choses, comme ceci : ::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:616
|
|
msgid "A trailing comma avoids the newline after the output::"
|
|
msgstr "Une virgule à la fin de l'instruction supprime le saut de ligne ::"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:625
|
|
msgid ""
|
|
"Note that the interpreter inserts a newline before it prints the next prompt "
|
|
"if the last line was not completed."
|
|
msgstr ""
|
|
"Notez que l'interpréteur insère un saut de ligne avant d'afficher l'invite "
|
|
"suivante si la dernière ligne n'était pas complète."
|
|
|
|
#: ../Doc/tutorial/introduction.rst:629
|
|
msgid "Footnotes"
|
|
msgstr "Notes"
|
|
|
|
#: ../Doc/tutorial/introduction.rst:630
|
|
msgid ""
|
|
"Since ``**`` has higher precedence than ``-``, ``-3**2`` will be interpreted "
|
|
"as ``-(3**2)`` and thus result in ``-9``. To avoid this and get ``9``, you "
|
|
"can use ``(-3)**2``."
|
|
msgstr ""
|
|
"Puisque ``**`` est prioritaire sur ``-``, ``-3 ** 2`` sera interprété ``-(3 "
|
|
"** 2)`` et vaudra donc ``-9``. Pour éviter cela et obtenir ``9``, utilisez "
|
|
"des parenthèses : ``(-3) ** 2``."
|
|
|
|
#: ../Doc/tutorial/introduction.rst:634
|
|
msgid ""
|
|
"Unlike other languages, special characters such as ``\\n`` have the same "
|
|
"meaning with both single (``'...'``) and double (``\"...\"``) quotes. The "
|
|
"only difference between the two is that within single quotes you don't need "
|
|
"to escape ``\"`` (but you have to escape ``\\'``) and vice versa."
|
|
msgstr ""
|
|
"Contrairement à d'autres langages, les caractères spéciaux comme ``\\n`` ont "
|
|
"la même signification entre guillemets (`\"...\"`) ou guillemets simples "
|
|
"(`'...'`). La seule différence est que dans une chaîne entre guillemets il "
|
|
"n'est pas nécessaire de protéger les guillemets simples et vice-versa."
|