Message313653
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 |
|
Date |
User |
Action |
Args |
2018-03-12 14:28:02 | FHTMitchell | set | recipients:
+ FHTMitchell |
2018-03-12 14:28:02 | FHTMitchell | set | messageid: <1520864882.07.0.467229070634.issue33055@psf.upfronthosting.co.za> |
2018-03-12 14:28:02 | FHTMitchell | link | issue33055 messages |
2018-03-12 14:28:01 | FHTMitchell | create | |
|