Python 3で数値クラスを実装しました。そのために何をする必要がありますか?
float(mynumber)
正しく動作しますか?
ドキュメントから、数値タイプのエミュレート:
object.__complex__(self)
object.__int__(self)
object.__long__(self)
object.__float__(self)
Called to implement the built-in functions complex(), int(), long(), and float().
Should return a value of the appropriate type.
実装__float__
または__int__
またはあなたが望むものは何でも...
abc
またはnumbers
モジュールを使用すると、エンドユーザーに役立つ可能性があることにも注意してください...