Pythonのクラスはすべて`type`のインスタンスであり、クラス定義時に`type`が呼び出される `type`をサブクラス化(メタクラス)することで、クラス生成の仕組みを自由に拡張できる Pythonのクラスシステムは、見た目以上に多くの仕組みが存在します。一般的に ...
prepare メソッドを使うと、クラスの辞書(namespace)をカスタマイズしたり、独自の辞書型を返せるため、クラス定義時の属性収集方法を柔軟に制御できる。 メタクラスの call は、クラスがインスタンス化される際の流れ(new → init)を総括し、クラス自身を ...
Python supports metaprogramming, which allows you to write code that manipulates other code. Two key features of metaprogramming in Python are **decorators** and **metaclasses**. ## **1. Decorators** ...
is a class of a class that defines how a class behaves. A class is itself an instance of a metaclass. A metaclass in Python is most commonly used for creating APIs, enforcing coding standards, or ...