X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=bindings%2Fpython%2Fnotmuch%2Fthreads.py;fp=bindings%2Fpython%2Fnotmuch%2Fthreads.py;h=d2e0a910e5794d3bf5b183dc436dfcd38a4005b9;hp=a6441640605b13bf909d8a7e77c5cc609e98718a;hb=7f74a400d197dac5cdf36960f68f63ce3eeff486;hpb=162687a99e412098729d639ed7bc27f01372cb84 diff --git a/bindings/python/notmuch/threads.py b/bindings/python/notmuch/threads.py index a6441640..d2e0a910 100644 --- a/bindings/python/notmuch/threads.py +++ b/bindings/python/notmuch/threads.py @@ -157,18 +157,15 @@ class Threads(Python3StringMixIn): return i def __nonzero__(self): - """Check if :class:`Threads` contains at least one more valid thread - - The existence of this function makes 'if Threads: foo' work, as - that will implicitely call len() exhausting the iterator if - __nonzero__ does not exist. This function makes `bool(Threads())` - work repeatedly. - - :return: True if there is at least one more thread in the - Iterator, False if not. None on a "Out-of-memory" error. - """ - return self._threads is not None and \ - self._valid(self._threads) > 0 + ''' + Implement truth value testing. If __nonzero__ is not + implemented, the python runtime would fall back to `len(..) > + 0` thus exhausting the iterator. + + :returns: True if the wrapped iterator has at least one more object + left. + ''' + return self._threads and self._valid(self._threads) _destroy = nmlib.notmuch_threads_destroy _destroy.argtypes = [NotmuchThreadsP]