forked from AFPy/python-docs-fr
193 lines
6.5 KiB
Plaintext
193 lines
6.5 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/library/numbers.rst:2
|
|
msgid ":mod:`numbers` --- Numeric abstract base classes"
|
|
msgstr ""
|
|
|
|
#: ../Doc/library/numbers.rst:10
|
|
msgid ""
|
|
"The :mod:`numbers` module (:pep:`3141`) defines a hierarchy of numeric :term:"
|
|
"`abstract base classes <abstract base class>` which progressively define "
|
|
"more operations. None of the types defined in this module can be "
|
|
"instantiated."
|
|
msgstr ""
|
|
|
|
#: ../Doc/library/numbers.rst:17
|
|
msgid ""
|
|
"The root of the numeric hierarchy. If you just want to check if an argument "
|
|
"*x* is a number, without caring what kind, use ``isinstance(x, Number)``."
|
|
msgstr ""
|
|
|
|
#: ../Doc/library/numbers.rst:22
|
|
msgid "The numeric tower"
|
|
msgstr ""
|
|
|
|
#: ../Doc/library/numbers.rst:26
|
|
msgid ""
|
|
"Subclasses of this type describe complex numbers and include the operations "
|
|
"that work on the built-in :class:`complex` type. These are: conversions to :"
|
|
"class:`complex` and :class:`bool`, :attr:`.real`, :attr:`.imag`, ``+``, ``-"
|
|
"``, ``*``, ``/``, :func:`abs`, :meth:`conjugate`, ``==``, and ``!=``. All "
|
|
"except ``-`` and ``!=`` are abstract."
|
|
msgstr ""
|
|
|
|
#: ../Doc/library/numbers.rst:34
|
|
msgid "Abstract. Retrieves the real component of this number."
|
|
msgstr ""
|
|
|
|
#: ../Doc/library/numbers.rst:38
|
|
msgid "Abstract. Retrieves the imaginary component of this number."
|
|
msgstr ""
|
|
|
|
#: ../Doc/library/numbers.rst:42
|
|
msgid ""
|
|
"Abstract. Returns the complex conjugate. For example, ``(1+3j).conjugate() "
|
|
"== (1-3j)``."
|
|
msgstr ""
|
|
|
|
#: ../Doc/library/numbers.rst:47
|
|
msgid ""
|
|
"To :class:`Complex`, :class:`Real` adds the operations that work on real "
|
|
"numbers."
|
|
msgstr ""
|
|
|
|
#: ../Doc/library/numbers.rst:50
|
|
msgid ""
|
|
"In short, those are: a conversion to :class:`float`, :func:`math.trunc`, :"
|
|
"func:`round`, :func:`math.floor`, :func:`math.ceil`, :func:`divmod`, ``//``, "
|
|
"``%``, ``<``, ``<=``, ``>``, and ``>=``."
|
|
msgstr ""
|
|
|
|
#: ../Doc/library/numbers.rst:54
|
|
msgid ""
|
|
"Real also provides defaults for :func:`complex`, :attr:`~Complex.real`, :"
|
|
"attr:`~Complex.imag`, and :meth:`~Complex.conjugate`."
|
|
msgstr ""
|
|
|
|
#: ../Doc/library/numbers.rst:60
|
|
msgid ""
|
|
"Subtypes :class:`Real` and adds :attr:`~Rational.numerator` and :attr:"
|
|
"`~Rational.denominator` properties, which should be in lowest terms. With "
|
|
"these, it provides a default for :func:`float`."
|
|
msgstr ""
|
|
|
|
#: ../Doc/library/numbers.rst:67 ../Doc/library/numbers.rst:71
|
|
msgid "Abstract."
|
|
msgstr "Résumé."
|
|
|
|
#: ../Doc/library/numbers.rst:76
|
|
msgid ""
|
|
"Subtypes :class:`Rational` and adds a conversion to :class:`int`. Provides "
|
|
"defaults for :func:`float`, :attr:`~Rational.numerator`, and :attr:"
|
|
"`~Rational.denominator`. Adds abstract methods for ``**`` and bit-string "
|
|
"operations: ``<<``, ``>>``, ``&``, ``^``, ``|``, ``~``."
|
|
msgstr ""
|
|
|
|
#: ../Doc/library/numbers.rst:83
|
|
msgid "Notes for type implementors"
|
|
msgstr ""
|
|
|
|
#: ../Doc/library/numbers.rst:85
|
|
msgid ""
|
|
"Implementors should be careful to make equal numbers equal and hash them to "
|
|
"the same values. This may be subtle if there are two different extensions of "
|
|
"the real numbers. For example, :class:`fractions.Fraction` implements :func:"
|
|
"`hash` as follows::"
|
|
msgstr ""
|
|
|
|
#: ../Doc/library/numbers.rst:104
|
|
msgid "Adding More Numeric ABCs"
|
|
msgstr ""
|
|
|
|
#: ../Doc/library/numbers.rst:106
|
|
msgid ""
|
|
"There are, of course, more possible ABCs for numbers, and this would be a "
|
|
"poor hierarchy if it precluded the possibility of adding those. You can add "
|
|
"``MyFoo`` between :class:`Complex` and :class:`Real` with::"
|
|
msgstr ""
|
|
|
|
#: ../Doc/library/numbers.rst:116
|
|
msgid "Implementing the arithmetic operations"
|
|
msgstr ""
|
|
|
|
#: ../Doc/library/numbers.rst:118
|
|
msgid ""
|
|
"We want to implement the arithmetic operations so that mixed-mode operations "
|
|
"either call an implementation whose author knew about the types of both "
|
|
"arguments, or convert both to the nearest built in type and do the operation "
|
|
"there. For subtypes of :class:`Integral`, this means that :meth:`__add__` "
|
|
"and :meth:`__radd__` should be defined as::"
|
|
msgstr ""
|
|
|
|
#: ../Doc/library/numbers.rst:149
|
|
msgid ""
|
|
"There are 5 different cases for a mixed-type operation on subclasses of :"
|
|
"class:`Complex`. I'll refer to all of the above code that doesn't refer to "
|
|
"``MyIntegral`` and ``OtherTypeIKnowAbout`` as \"boilerplate\". ``a`` will be "
|
|
"an instance of ``A``, which is a subtype of :class:`Complex` (``a : A <: "
|
|
"Complex``), and ``b : B <: Complex``. I'll consider ``a + b``:"
|
|
msgstr ""
|
|
|
|
#: ../Doc/library/numbers.rst:156
|
|
msgid "If ``A`` defines an :meth:`__add__` which accepts ``b``, all is well."
|
|
msgstr ""
|
|
|
|
#: ../Doc/library/numbers.rst:158
|
|
msgid ""
|
|
"If ``A`` falls back to the boilerplate code, and it were to return a value "
|
|
"from :meth:`__add__`, we'd miss the possibility that ``B`` defines a more "
|
|
"intelligent :meth:`__radd__`, so the boilerplate should return :const:"
|
|
"`NotImplemented` from :meth:`__add__`. (Or ``A`` may not implement :meth:"
|
|
"`__add__` at all.)"
|
|
msgstr ""
|
|
|
|
#: ../Doc/library/numbers.rst:164
|
|
msgid ""
|
|
"Then ``B``'s :meth:`__radd__` gets a chance. If it accepts ``a``, all is "
|
|
"well."
|
|
msgstr ""
|
|
|
|
#: ../Doc/library/numbers.rst:166
|
|
msgid ""
|
|
"If it falls back to the boilerplate, there are no more possible methods to "
|
|
"try, so this is where the default implementation should live."
|
|
msgstr ""
|
|
|
|
#: ../Doc/library/numbers.rst:169
|
|
msgid ""
|
|
"If ``B <: A``, Python tries ``B.__radd__`` before ``A.__add__``. This is ok, "
|
|
"because it was implemented with knowledge of ``A``, so it can handle those "
|
|
"instances before delegating to :class:`Complex`."
|
|
msgstr ""
|
|
|
|
#: ../Doc/library/numbers.rst:174
|
|
msgid ""
|
|
"If ``A <: Complex`` and ``B <: Real`` without sharing any other knowledge, "
|
|
"then the appropriate shared operation is the one involving the built in :"
|
|
"class:`complex`, and both :meth:`__radd__` s land there, so ``a+b == b+a``."
|
|
msgstr ""
|
|
|
|
#: ../Doc/library/numbers.rst:179
|
|
msgid ""
|
|
"Because most of the operations on any given type will be very similar, it "
|
|
"can be useful to define a helper function which generates the forward and "
|
|
"reverse instances of any given operator. For example, :class:`fractions."
|
|
"Fraction` uses::"
|
|
msgstr ""
|