I have the following class:
from __future__ import print_function
class Proxy(object):
__slots__ = [\'_value\']
def __init__(self, obj):
se
One of the goals of PEP3100 (Miscellaneous Python 3.0 Plans) was to:
[remove]
__oct__
,__hex__
: use__index__
inoct()
andhex()
instead.
To make this work, you need to implement __index__
, likely as:
def __index__(self):
# or self._value if you know _value is an integer already
return operator.index(self._value)
You can see the commit that changed this behavior here:
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.