per page, with , order by , clip by
Results of 1 - 10 of about 33 for subclass (0.015 sec.)
abc --- 抽象基底クラス 14005
abc --- 抽象基底クラス ソースコード: Lib/abc.py このモジュールは Python に PEP 3119 で概要が示された 抽象基底クラス (ABC) を定義する基盤を提供します。なぜこれが Python に付け加えられたかについてはその PEP を参照してください。 (ABC に基づいた ... クラス(組み込み型でも構いません)と無関係な ABC を "仮想的サブクラス" として登録できます -- これらとその子孫は組み込み関数 issubclass() によって登録した ABC のサブクラスと判定されますが、登録した ABC は MRO (Method Resolution Order, メソッド解決順)には現れ ... けでなく)呼び出し可能になるわけでもありません。 [ 1 ] メタクラスが ABCMeta のクラスには、次のメソッドがあります。 register ( subclass ) subclass を "仮想的サブクラス" としてこの ABC に登録します。たとえば: from abc import ABC class MyABC ( ABC ): pass MyAB ... C . register ( tuple ) assert issubclass ( tuple , MyABC ) assert isinstance ((), MyABC ) バージョン 3.3 で変更: クラスデコレータとして使うことができるように、登録 ...
https://man.mtool.work/python/3.14/library/abc.html
3. データモデル 11117
3. データモデル 3.1. オブジェクト、値、および型 オブジェクト は、Python がデータを抽象化したものです。 Python プログラム内のすべてのデータは、オブジェクトまたはオブジェクト間の関係として表されます。 コードもオブジェクトで表されます。 すべて ... スのメソッド解決順序をカスタマイズできます。 クラスのインスタンス化の際に呼び出され、結果は __mro__ に格納されます。 type. __subclasses__ ( ) Each class keeps a list of weak references to its immediate subclasses. This method returns a list of all those re ... ferences still alive. The list is in definition order. Example: >>> class A : pass >>> class B ( A ): pass >>> A . __subclasses__ () [<class 'B'>] 3.2.11. クラスインスタンス (class instance) クラスインスタンスはクラスオブジェクトを呼び出すことで作成 ... 性は空のイテレータとなります。 3.3.3. クラス生成をカスタマイズする クラスが他のクラスを継承するときに必ず、親クラスの __init_subclass__() が呼び出されます。これを利用すると、サブクラスの挙動を変更するクラスを書くことができます。これは、クラスデコレータとと ...
https://man.mtool.work/python/3.14/reference/datamodel.html
型オブジェクト 10797
型オブジェクト type PyTypeObject 次に属します: Limited API (不透明な構造体として). 組み込み型を記述する際に用いられる、オブジェクトを表す C 構造体です。 PyTypeObject PyType_Type 次に属します: Stable ABI . 型オブジェクト自身の型オブジェクトで ... o に機能 feature が設定されていれば、ゼロ以外を返します。 型の機能は、それぞれ 1 ビットのフラグで表します。 int PyType_FastSubclass ( PyTypeObject * type , int flag ) 型オブジェクト type にサブクラスフラグ flag が設定されていれば、ゼロ以外を返します。 サ ... ブクラスフラグは Py_TPFLAGS_*_SUBCLASS で表します。 この関数は、一般的な型の多くの _Check 関数で使われています。 参考 PyObject_TypeCheck() は、サブクラスフラグの ... 次に属します: Stable ABI . a が b のサブタイプの場合に真を返します。 この関数が調べるのは実際のサブタイプ関係だけで、 b の __subclasscheck__() は呼び出しません。 issubclass() と同じ検査を行うには PyObject_IsSubclass() を呼び出してください。 PyObject * PyTy ...
https://man.mtool.work/python/3.14/c-api/type.html
型オブジェクトの構造体 9834
型オブジェクトの構造体 新しい型を定義する PyTypeObject 構造体は、Python のオブジェクトシステムで特に重要な構造体の 1 つです。 型オブジェクトは PyObject_* 関数や PyType_* 関数で扱えますが、ほとんどの Python アプリケーションにとって関心のある ... ? ? tp_is_gc inquiry X X < tp_bases > PyObject * __bases__ ~ < tp_mro > PyObject * __mro__ ~ [ tp_cache ] PyObject * [ tp_subclasses ] void * __subclasses__ [ tp_weaklist ] PyObject * ( tp_del ) destructor [ tp_version_tag ] unsigned int tp_finalize des ... 用 */ PyObject * tp_bases ; PyObject * tp_mro ; /* メソッド解決順序 */ PyObject * tp_cache ; /* 現在は未使用 */ void * tp_subclasses ; /* 静的な組み込み型ではインデックス */ PyObject * tp_weaklist ; /* 静的な組み込み型では未使用 */ destructor tp_del ; / ... とを確認してください。 Python はこれを検証しません。 Added in version 3.12. 継承: このフラグは継承されます。 Py_TPFLAGS_LONG_SUBCLASS Py_TPFLAGS_LIST_SUBCLASS Py_TPFLAGS_TUPLE_SUBCLASS Py_TPFLAGS_BYTES_SUBCLASS Py_TPFLAGS_UNICODE_SUBCLASS Py_TPFLAGS_DICT_S ...
https://man.mtool.work/python/3.14/c-api/typeobj.html
unittest.mock --- 入門 9513
unittest.mock --- 入門 Added in version 3.3. Mock を使う モックでメソッドにパッチを当てる 一般的な Mock の使い方の中には次のものがあります: メソッドにパッチを当てる オブジェクトに対するメソッド呼び出しを記録する システムの他の部分からメソッ ... 防げます。 シグネチャは任意のキーワード引数 ( **kwargs ) を受け取り、それらをモックのコンストラクタに渡す形です。 >>> class Subclass ( MagicMock ): ... def _get_child_mock ( self , / , ** kwargs ): ... return MagicMock ( ** kwargs ) ... >>> mymock = Subcl ... ass () >>> mymock . foo <MagicMock name='mock.foo' id='...'> >>> assert isinstance ( mymock , Subclass ) >>> assert not isinstance ( mymock . foo , Subclass ) >>> assert not isinstance ( mymock (), Subclass ) [ 2 ] この規則の ...
https://man.mtool.work/python/3.14/library/unittest.mock-examples.html
What's New In Python 3.6 9176
What's New In Python 3.6 エディタ : Elvis Pranskevichus < elvis @ magic . io >, Yury Selivanov < yury @ magic . io > この記事では 3.5 と比較した Python 3.6 の新機能を解説します。 Python 3.6 は2016年12月23日にリリースされました。 全詳細につい ... カスタマイズを簡単に メタクラスを使わずにサブクラスの作成をカスタマイズできるようになりました。 新しいクラスメソッド __init_subclass__ は、新しいサブクラスが作成されるたびに基底クラスで呼び出されます。 class PluginBase : subclasses = [] def __init_subclas ... s__ ( cls , ** kwargs ): super () . __init_subclass__ ( ** kwargs ) cls . subclasses . append ( cls ) class Plugin1 ( PluginBase ): pass class Plugin2 ( PluginBase ): pass __ ... init_subclass__() の実装内で引数なしの super() が正しく動作するように、独自のメタクラスは名前空間の新しいエントリー __classcell__ を typ ...
https://man.mtool.work/python/3.14/whatsnew/3.6.html
変更履歴 9176
変更履歴 次の Python バージョン リリース日: XXXX-XX-XX セキュリティ gh-160499 : Fix unbounded memory growth in asyncio TLS connections when a peer stops reading but keeps sending records that make OpenSSL generate its own replies (such as T ... aded code using functools.wraps() since 3.14.7. gh-151060 : Fix a crash or memory corruption in sum() when summing a float subclass instance into a complex running total. ライブラリ gh-137549 : asyncio.timeout() now inserts TimeoutError into the context ... ts early because of an allocation error. gh-159739 : Prevent free-threaded builds from interning and immortalizing complex subclasses in code object constants. gh-159739 : Fix a reference leak in binary, ternary, and comparison operations on weak referen ... nvolving property accessors or names. gh-159739 : Fix a crash in warnings.warn() when skip_file_prefixes is an empty tuple subclass. Propagate allocation errors when creating the fallback filename. gh-159431 : Fix an assertion failure, or an immortal obj ...
https://man.mtool.work/python/3.14/whatsnew/changelog.html
shelve --- Python オブジェクトの永続化 8855
shelve --- Python オブジェクトの永続化 ソースコード: Lib/shelve.py "シェルフ (shelf, 棚)" は辞書に似た永続性を持つオブジェクトです。 "dbm" データベースとの違いは、シェルフの値 (キーではありません!) は実質上どんな Python オブジェクトにも --- ... を使うようになりました。 class shelve. BsdDbShelf ( dict , protocol = None , writeback = False , keyencoding = 'utf-8' ) A subclass of Shelf which exposes first() , next() , previous() , last() and set_location() methods. These are available in the third ... on as for the Shelf class. class shelve. DbfilenameShelf ( filename , flag = 'c' , protocol = None , writeback = False ) A subclass of Shelf which accepts a filename instead of a dict-like object. The underlying file will be opened using dbm.open() . By ...
https://man.mtool.work/python/3.14/library/shelve.html
オブジェクトプロトコル (object protocol) 8534
オブジェクトプロトコル (object protocol) PyObject * Py_GetConstant ( unsigned int constant_id ) 次に属します: Stable ABI (バージョン 3.13 より). 定数への 強参照 を取得します。 constant_id が無効な場合、例外を設定して NULL を返します。 const ... トを返すのではなく TypeError が送出されます。 引数が NULL の場合は bytes オブジェクト b'<NULL>' を返します。 int PyObject_IsSubclass ( PyObject * derived , PyObject * cls ) 次に属します: Stable ABI . クラス derived がクラス cls と同一であるか、そこから派生 ... してチェックします。 少なくとも1つのチェックで 1 が返ったとき、結果は 1 となり、それ以外のとき 0 になります。 If cls has a __subclasscheck__() method, it will be called to determine the subclass status as described in PEP 3119 . Otherwise, derived is a sub ... class of cls if it is a direct or indirect subclass, i.e. contained in cls.__mro__ . 通常はクラスオブジェクト、つまり type またはその派生クラスのインスタンスだけがクラスとみな ...
https://man.mtool.work/python/3.14/c-api/object.html
importlib.metadata -- パッケージメタデータへのアクセス 8214
importlib.metadata -- パッケージメタデータへのアクセス Added in version 3.8. バージョン 3.10 で変更: importlib.metadata は暫定的なものではなくなりました。 ソースコード: Lib/importlib/metadata/__init__.py importlib.metadata は、インストール済 ... an abstract object that represents the metadata for a Python Distribution Package . You can get the concrete Distribution subclass instance for an installed distribution package by calling the distribution() function: >>> from importlib.metadata import ... ht by the consumer. In practice, to support finding distribution package metadata in locations other than the file system, subclass Distribution and implement the abstract methods. Then from a custom finder, return instances of this derived Distribution ...
https://man.mtool.work/python/3.14/library/importlib.metadata.html
PREV 1 2 3 4 NEXT