在python 3中覆盖__hex__?

在python 3中覆盖__hex__?,第1张

在python 3中覆盖__hex__?

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 convertingnon-ints before formatting in a base.Add a bin() builtin.


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5631428.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-12-16
下一篇2022-12-15

发表评论

登录后才能评论

评论列表(0条)

    保存