[issue19995] hex() and %x, oct() and %o do not behave the same

Ethan Furman report at bugs.python.org
Mon Dec 16 21:48:46 CET 2013


Ethan Furman added the comment:

Antoine Pitrou opined:
----------------------
> I'm with Guido: it doesn't really make sense to allow __index__ but not __int__ on
> a type. So trying __index__ in str.format() sounds like a distraction.

  --> hex(3.14)  # calls __index__
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
  TypeError: 'float' object cannot be interpreted as an integer

  --> '%x' % 3.14  # calls __int__
  '3'

One of those behaviours is wrong.  Which?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19995>
_______________________________________


More information about the Python-bugs-list mailing list