I have a script that basically returns a tuple from a function:
results = some_function()
Then I'm checking to see if there are any results like so:
if results:
do_something()
This returns True
when the tuple has two empty lists. When I use debug mode my results
are ([], [])
. Running len(results)
produces a length of 2
.
Interestingly, if I do the following:
results = ([])
print(len(results))
It prints 0
. Why is that adding another list prints 2
?
Should I be overriding the class method __len__
from the function producing the tuple?