New submission from FHTMitchell <fergus....@gmail.com>: Every object which has a corresponding dunder protocol also implements said protocol with one exception:
>>> 'hello'.__str__() 'hello' >>> (3.14).__float__() 3.14 >>> (101).__int__() 101 >>> True.__bool__() True >>> iter(range(10)).__iter__() <range_iterator at 0xf6b08b0> >>> b'hello'.__bytes__() --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) ----> 1 b'hello'.__bytes__() AttributeError: 'bytes' object has no attribute '__bytes__' This was brought up on SO as being inconsistent: https://stackoverflow.com/questions/49236655/bytes-doesnt-have-bytes-method/49237034?noredirect=1#comment85477673_49237034 ---------- components: Interpreter Core messages: 313653 nosy: FHTMitchell priority: normal severity: normal status: open title: bytes does not implement __bytes__() type: behavior versions: Python 3.6, Python 3.7, Python 3.8 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue33055> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com