Message322104
Relevant SO answer : https://stackoverflow.com/a/41861322/2610955
Ref : https://docs.python.org/3/reference/datamodel.html#object.__bool__
> If a class defines neither __len__() nor __bool__(), all its instances are considered true.
I don't know why it's not implemented and the SO answer comments has some discussion. Maybe this can be clarified in the doc.
➜ cpython git:(master) rlwrap ./python
Python 3.8.0a0 (heads/master:56868f9, Jul 21 2018, 14:28:31)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from queue import PriorityQueue
>>> len(PriorityQueue([1]))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: object of type 'PriorityQueue' has no len()
Thanks |
|
Date |
User |
Action |
Args |
2018-07-21 16:18:16 | xtreak | set | recipients:
+ xtreak, rhettinger, porton |
2018-07-21 16:18:16 | xtreak | set | messageid: <1532189896.3.0.56676864532.issue34180@psf.upfronthosting.co.za> |
2018-07-21 16:18:16 | xtreak | link | issue34180 messages |
2018-07-21 16:18:16 | xtreak | create | |
|