0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

カスタマイズ特殊名一覧

Last updated at Posted at 2021-01-14

Python 言語リファレンス - 3. データモデル
"__" で始まるカスタマイズするための特殊名の一覧

基本的なカスタマイズ

object. __new__ (cls, [...])
object. __init__ (self, [...])
object. __del__ (self)
object. __repr__ (self)
object. __str__ (self)
object. __bytes__ (self)
object. __format__ (self, fmtspec)
object. __lt__ (self, other)
object. __le__ (self, other)
object. __eq__ (self, other)
object. __ne__ (self, other)
object. __gt__ (self, other)
object. __ge__ (self, other)
object. __hash__ (self)
object. __bool__ (self)

属性値アクセスをカスタマイズする

object. __getattr__ (self, name)
object. __getattribute__ (self, name)
object. __setattr__ (self, name, value)
object. __delattr__ (self, name)
object. __dir__ (self)

デスクリプタの実装

object. __get__ (self, instance, owner=None)
object. __set__ (self, instance, value)
object. __delete__ (self, instance)
object. __objclass__

デスクリプタの呼び出し

object. __slots__

クラス生成をカスタマイズする

object. __init_subclass__ (cls)
object. __set_name__ (self, owner, name)
object. __mro_entries__ (self, bases)
object. __prepare__ (metacls, name, bases)

インスタンスのカスタマイズとサブクラス チェック

class. __instancecheck__ (self, instance)
class. __subclasscheck__ (self, instance)

ジェネリック型をエミュレートする

object. __class_getitem__ (cls, key)

呼び出し可能オブジェクトをエミュレートする

object. __call__ (self[, args...])

コンテナをエミュレートする

object. __len__ (self)
object. __length_hint__ (self)
object. __getitem__ (self, key)
object. __setitem__ (self, key, value)
object. __delitem__ (self, key)
object. __missing__ (self, key)
object. __iter__ (self)
object. __reserved__ (self)
object. __contains__ (self, item)

数値型をエミュレートする

object. __add__ (self, other)
object. __sub__ (self, other)
object. __mul__ (self, other)
object. __matmul__ (self, other)
object. __truediv__ (self, other)
object. __floordiv__ (self, other)
object. __mod__ (self, other)
object. __divmod__ (self, other)
object. __pow__ (self, other [,modulo])
object. __lshift__ (self, other)
object. __rshift__ (self, other)
object. __and__ (self, other)
object. __xor__ (self, other)
object. __or__ (self, other)

object. __radd__ (self, other)
object. __rsub__ (self, other)
object. __rmul__ (self, other)
object. __rmatmul__ (self, other)
object. __rtruediv__ (self, other)
object. __rfloordiv__ (self, other)
object. __rmod__ (self, other)
object. __rdivmod__ (self, other)
object. __rpow__ (self, other [,modulo])
object. __rlshift__ (self, other)
object. __rrshift__ (self, other)
object. __rand__ (self, other)
object. __rxor__ (self, other)
object. __ror__ (self, other)

object. __iadd__ (self, other)
object. __isub__ (self, other)
object. __imul__ (self, other)
object. __imatmul__ (self, other)
object. __itruediv__ (self, other)
object. __ifloordiv__ (self, other)
object. __imod__ (self, other)
object. __ipow__ (self, other [,modulo])
object. __ilshift__ (self, other)
object. __irshift__ (self, other)
object. __iand__ (self, other)
object. __ixor__ (self, other)
object. __ior__ (self, other)

object. __neg__ (self)
object. __pos__ (self)
object. __abs__ (self)
object. __invert__ (self)

object. __complex__ (self)
object. __int__ (self)
object. __float__ (self)
object. __index__ (self)

object. __round__ (self [,ndigits])
object. __trunc__ (self)
object. __floor__ (self)
object. __ceil__ (self)

with 文とコンテキストマネージャー

object. __enter__ (self)
object. __exit__ (self, exc_type, exc_value, traceback)

クラスパターンマッチの位置引数のカスタマイズ

object. __match_args__

buffer型のエミュレート

object. __buffer__ (self, flags)
object. __release_buffer__ (self, buffer)

待機可能オブジェクト

object. __await__ (self)

非同期イテレータ

object. __aiter__ (self)
object. __anext__ (self)

非同期コンテキストマネージャー

object. __aenter__ (self)
object. __aexit__ (self, exc_type, exc_value, traceback)


実装したい機能の名前が出てこないとき(例えるなら、面識があって、名前も知っているハズなのに、その相手の名前がでてこない、あの感じ)のための一覧。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?