Results of 1 - 1 of about 1 for MyIntegral (0.000 sec.)
- numbers --- 数の抽象基底クラス 9414
- numbers --- 数の抽象基底クラス ソースコード: Lib/numbers.py numbers モジュール ( PEP 3141 ) は、下位になるほど多くの演算を定義する、数値の 抽象基底クラス の階層を定義しています。 このモジュールで定義する型は、どれもインスタンス化を目的とした
...で演算するように実装します。 Integral のサブタイプでは、 __add__() と __radd__() を次のように定義するということです。 class MyIntegral ( Integral ): def __add__ ( self , other ): if isinstance ( other , MyIntegral ): return do_my_adding_stuff ( self , other...my_other_adding_stuff ( self , other ) else : return NotImplemented def __radd__ ( self , other ): if isinstance ( other , MyIntegral ): return do_my_adding_stuff ( other , self ) elif isinstance ( other , OtherTypeIKnowAbout ): return do_my_other_adding_s...re are 5 different cases for a mixed-type operation on subclasses of Complex . All of the above code that doesn't refer to MyIntegral and OtherTypeIKnowAbout is referred to as "boilerplate". In this description, a is an instance of A and b is an instance o... - https://man.mtool.work/python/3.14/library/numbers.html
PREV
1
NEXT