PEP3100(杂项Python 3.0计划)的目标之一是:
[删除] __oct__
,__hex__
使用:__index__
在oct()
和hex()
代替。
要进行这项工作,您需要实现__index__
,可能是:
def __index__(self):
# or self._value if you kNow _value is an integer already
return operator.index(self._value)
您可以在此处查看更改此行为的提交:
r55905 | georg.brandl | 2007-06-11 10:02:26 -0700 (Mon, 11 Jun 2007) | 5
lines
Remove __oct__ and __hex__ and use __index__ for converting
non-ints before formatting in a base.
Add a bin() builtin.