A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-112.py
1classA:
2def__bool__(self):returnFalse
3def__len__(self):return10
4print(bool(A()),len(A()))
Classes
Answer & explanation
Console output
False 10
Why
For truth testing Python tries __bool__ first; only if it is absent does it fall back to __len__. Here __bool__ returns False, so bool(A()) is False even though __len__ reports 10. len() is a separate protocol and returns 10 directly.