Author FHTMitchell
Recipients FHTMitchell
Date 2018-03-12.14:28:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1520864882.07.0.467229070634.issue33055@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2018-03-12 14:28:02FHTMitchellsetrecipients: + FHTMitchell
2018-03-12 14:28:02FHTMitchellsetmessageid: <1520864882.07.0.467229070634.issue33055@psf.upfronthosting.co.za>
2018-03-12 14:28:02FHTMitchelllinkissue33055 messages
2018-03-12 14:28:01FHTMitchellcreate