# SOME DESCRIPTIVE TITLE. # Copyright (C) 1990-2021, Python Software Foundation # This file is distributed under the same license as the Python package. # # Translators: # 秘湯 , 2016 msgid "" msgstr "" "Project-Id-Version: Python 2.7\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-01 01:01+0900\n" "PO-Revision-Date: 2019-09-01 05:18+0000\n" "Last-Translator: tomo\n" "Language-Team: Japanese (http://www.transifex.com/python-doc/python-27/" "language/ja/)\n" "Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../library/abc.rst:2 msgid ":mod:`abc` --- Abstract Base Classes" msgstr ":mod:`abc` --- 抽象基底クラス" #: ../../library/abc.rst:12 msgid "**Source code:** :source:`Lib/abc.py`" msgstr "**ソースコード:** :source:`Lib/abc.py`" #: ../../library/abc.rst:16 msgid "" "This module provides the infrastructure for defining :term:`abstract base " "classes ` (ABCs) in Python, as outlined in :pep:`3119`; " "see the PEP for why this was added to Python. (See also :pep:`3141` and the :" "mod:`numbers` module regarding a type hierarchy for numbers based on ABCs.)" msgstr "" "このモジュールは Python に :pep:`3119` で概要が示された :term:`抽象基底クラ" "ス ` (ABC) を定義する基盤を提供します。なぜこれが " "Python に付け加えられたかについてはその PEP を参照してください。 (ABC に基づ" "いた数の型階層を扱った :pep:`3141` と :mod:`numbers` モジュールも参照してくだ" "さい。)" #: ../../library/abc.rst:21 msgid "" "The :mod:`collections` module has some concrete classes that derive from " "ABCs; these can, of course, be further derived. In addition, the :mod:" "`collections` module has some ABCs that can be used to test whether a class " "or instance provides a particular interface, for example, if it is hashable " "or if it is a mapping." msgstr "" #: ../../library/abc.rst:28 msgid "This module provides the following class:" msgstr "このモジュールは以下のクラスを提供します:" #: ../../library/abc.rst:32 msgid "Metaclass for defining Abstract Base Classes (ABCs)." msgstr "抽象基底クラス(ABC)を定義するためのメタクラス。" #: ../../library/abc.rst:34 msgid "" "Use this metaclass to create an ABC. An ABC can be subclassed directly, and " "then acts as a mix-in class. You can also register unrelated concrete " "classes (even built-in classes) and unrelated ABCs as \"virtual subclasses\" " "-- these and their descendants will be considered subclasses of the " "registering ABC by the built-in :func:`issubclass` function, but the " "registering ABC won't show up in their MRO (Method Resolution Order) nor " "will method implementations defined by the registering ABC be callable (not " "even via :func:`super`). [#]_" msgstr "" "ABC を作るときにこのメタクラスを使います。ABC は直接的にサブクラス化すること" "ができ、ミックスイン(mix-in)クラスのように振る舞います。また、無関係な具象ク" "ラス(組み込み型でも構いません)と無関係な ABC を \"仮想的サブクラス\" として登" "録できます -- これらとその子孫は組み込み関数 :func:`issubclass` によって登録" "した ABC のサブクラスと判定されますが、登録した ABC は MRO (Method " "Resolution Order, メソッド解決順)には現れませんし、この ABC のメソッド実装が" "(:func:`super` を通してだけでなく)呼び出し可能になるわけでもありません。 [#]_" #: ../../library/abc.rst:43 msgid "" "Classes created with a metaclass of :class:`ABCMeta` have the following " "method:" msgstr "" "メタクラス :class:`ABCMeta` を使って作られたクラスには以下のメソッドがありま" "す:" #: ../../library/abc.rst:47 msgid "" "Register *subclass* as a \"virtual subclass\" of this ABC. For example::" msgstr "" "*subclass* を \"仮想的サブクラス\" としてこの ABC に登録します。たとえば::" #: ../../library/abc.rst:60 msgid "You can also override this method in an abstract base class:" msgstr "また、次のメソッドを抽象基底クラスの中でオーバーライドできます:" #: ../../library/abc.rst:64 msgid "(Must be defined as a class method.)" msgstr "(クラスメソッドとして定義しなければなりません。)" #: ../../library/abc.rst:66 msgid "" "Check whether *subclass* is considered a subclass of this ABC. This means " "that you can customize the behavior of ``issubclass`` further without the " "need to call :meth:`register` on every class you want to consider a subclass " "of the ABC. (This class method is called from the :meth:`__subclasscheck__` " "method of the ABC.)" msgstr "" "*subclass* がこの ABC のサブクラスと見なせるかどうかチェックします。これに" "よって ABC のサブクラスと見なしたい全てのクラスについて :meth:`register` を呼" "び出すことなく ``issubclass`` の振る舞いをさらにカスタマイズできます。 (この" "クラスメソッドは ABC の :meth:`__subclasscheck__` メソッドから呼び出されま" "す。)" #: ../../library/abc.rst:72 msgid "" "This method should return ``True``, ``False`` or ``NotImplemented``. If it " "returns ``True``, the *subclass* is considered a subclass of this ABC. If it " "returns ``False``, the *subclass* is not considered a subclass of this ABC, " "even if it would normally be one. If it returns ``NotImplemented``, the " "subclass check is continued with the usual mechanism." msgstr "" "このメソッドは ``True``, ``False`` または ``NotImplemented`` を返さなければな" "りません。``True`` を返す場合は、*subclass* はこの ABC のサブクラスと見なされ" "ます。``False`` を返す場合は、*subclass* はたとえ通常の意味でサブクラスであっ" "ても ABC のサブクラスではないと見なされます。``NotImplemented`` の場合、サブ" "クラスチェックは通常のメカニズムに戻ります。" #: ../../library/abc.rst:82 msgid "" "For a demonstration of these concepts, look at this example ABC definition::" msgstr "この概念のデモとして、次の ABC 定義の例を見てください::" #: ../../library/abc.rst:112 msgid "" "The ABC ``MyIterable`` defines the standard iterable method, :meth:" "`~iterator.__iter__`, as an abstract method. The implementation given here " "can still be called from subclasses. The :meth:`get_iterator` method is " "also part of the ``MyIterable`` abstract base class, but it does not have to " "be overridden in non-abstract derived classes." msgstr "" "ABC ``MyIterable`` は標準的なイテラブルのメソッド :meth:`~iterator.__iter__` " "を抽象メソッドとして定義します。ここで与えられている抽象クラスの実装は、サブ" "クラスから呼び出すことができます。 :meth:`get_iterator` メソッドも " "``MyIterable`` 抽象基底クラスの一部ですが、抽象的でない派生クラスはこれをオー" "バーライドする必要はありません。" #: ../../library/abc.rst:118 msgid "" "The :meth:`__subclasshook__` class method defined here says that any class " "that has an :meth:`~iterator.__iter__` method in its :attr:`~object." "__dict__` (or in that of one of its base classes, accessed via the :attr:" "`~class.__mro__` list) is considered a ``MyIterable`` too." msgstr "" "ここで定義されるクラスメソッド :meth:`__subclasshook__` の意味は、 :meth:" "`~iterator.__iter__` メソッドがクラスの(または :attr:`~class.__mro__` でアク" "セスされる基底クラスの一つの) :attr:`~object.__dict__` にある場合にもそのクラ" "スが ``MyIterable`` だと見なされるということです。" #: ../../library/abc.rst:123 msgid "" "Finally, the last line makes ``Foo`` a virtual subclass of ``MyIterable``, " "even though it does not define an :meth:`~iterator.__iter__` method (it uses " "the old-style iterable protocol, defined in terms of :meth:`__len__` and :" "meth:`__getitem__`). Note that this will not make ``get_iterator`` " "available as a method of ``Foo``, so it is provided separately." msgstr "" "最後に、一番下の行は ``Foo`` を :meth:`~iterator.__iter__` メソッドを定義しな" "いにもかかわらず ``MyIterable`` の仮想的サブクラスにします(``Foo`` は古い様式" "の :meth:`__len__` と :meth:`__getitem__` を用いたイテレータプロトコルを使っ" "ています。)。これによって ``Foo`` のメソッドとして ``get_iterator`` が手に入" "るわけではないことに注意してください。それは別に提供されています。" #: ../../library/abc.rst:130 msgid "It also provides the following decorators:" msgstr "以下のデコレータも提供しています:" #: ../../library/abc.rst:134 msgid "A decorator indicating abstract methods." msgstr "抽象メソッドを示すデコレータです。" #: ../../library/abc.rst:136 msgid "" "Using this decorator requires that the class's metaclass is :class:`ABCMeta` " "or is derived from it. A class that has a metaclass derived from :class:" "`ABCMeta` cannot be instantiated unless all of its abstract methods and " "properties are overridden. The abstract methods can be called using any of " "the normal 'super' call mechanisms." msgstr "" "このデコレータを使うにはクラスのメタクラスが :class:`ABCMeta` であるかまたは" "派生したものであることが求められます。 :class:`ABCMeta` から派生したメタクラ" "スを持つクラスは全ての抽象メソッドおよびプロパティをオーバーライドしない限り" "インスタンス化できません。抽象メソッドは普通の 'super' 呼び出し機構を使って呼" "び出すことができます。" #: ../../library/abc.rst:144 msgid "" "Dynamically adding abstract methods to a class, or attempting to modify the " "abstraction status of a method or class once it is created, are not " "supported. The :func:`abstractmethod` only affects subclasses derived using " "regular inheritance; \"virtual subclasses\" registered with the ABC's :meth:" "`register` method are not affected." msgstr "" "クラスに動的に抽象メソッドを追加する、あるいはメソッドやクラスが作られた後か" "ら抽象的かどうかの状態を変更しようと試みることは、サポートされません。 :func:" "`abstractmethod` が影響を与えるのは正規の継承により派生したサブクラスのみで、" "ABC の :meth:`register` メソッドで登録された \"仮想的サブクラス\" は影響され" "ません。" #: ../../library/abc.rst:150 ../../library/abc.rst:179 msgid "Usage::" msgstr "使い方::" #: ../../library/abc.rst:160 msgid "" "Unlike Java abstract methods, these abstract methods may have an " "implementation. This implementation can be called via the :func:`super` " "mechanism from the class that overrides it. This could be useful as an end-" "point for a super-call in a framework that uses cooperative multiple-" "inheritance." msgstr "" "Java の抽象メソッドと違い、これらの抽象メソッドは実装を持ち得ます。この実装" "は :func:`super` メカニズムを通してそれをオーバーライドしたクラスから呼び出す" "ことができます。これは協調的多重継承を使ったフレームワークにおいて super 呼び" "出しの終点として有効です。" #: ../../library/abc.rst:170 msgid "" "A subclass of the built-in :func:`property`, indicating an abstract property." msgstr "" "組み込みの :func:`property` のサブクラスで、抽象プロパティであることを示しま" "す。" #: ../../library/abc.rst:172 msgid "" "Using this function requires that the class's metaclass is :class:`ABCMeta` " "or is derived from it. A class that has a metaclass derived from :class:" "`ABCMeta` cannot be instantiated unless all of its abstract methods and " "properties are overridden. The abstract properties can be called using any " "of the normal 'super' call mechanisms." msgstr "" "この関数を使うにはクラスのメタクラスが :class:`ABCMeta` であるかまたは派生し" "たものであることが求められます。 :class:`ABCMeta` から派生したメタクラスを持" "つクラスは全ての抽象メソッドおよびプロパティをオーバーライドしない限りインス" "タンス化できません。抽象プロパティは普通の 'super' 呼び出し機構を使って呼び出" "すことができます。" #: ../../library/abc.rst:187 msgid "" "This defines a read-only property; you can also define a read-write abstract " "property using the 'long' form of property declaration::" msgstr "" "この例は読み取り専用のプロパティを定義しています。プロパティ定義の「長い」形" "式の宣言を使って、読み書き出来る抽象プロパティを定義することができます::" #: ../../library/abc.rst:198 msgid "Footnotes" msgstr "注記" #: ../../library/abc.rst:199 msgid "" "C++ programmers should note that Python's virtual base class concept is not " "the same as C++'s." msgstr "" "C++ プログラマは Python の仮想的基底クラスの概念は C++ のものと同じではないと" "いうことを銘記すべきです。"