X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=bindings%2Fpython%2Fnotmuch%2Fmessages.py;h=59ef40afee1ea2103f8273492c57b5debb4c9479;hb=7f74a400d197dac5cdf36960f68f63ce3eeff486;hp=251fa3a3457f77ef42831925b7021264c4d9e3be;hpb=162687a99e412098729d639ed7bc27f01372cb84;p=notmuch diff --git a/bindings/python/notmuch/messages.py b/bindings/python/notmuch/messages.py index 251fa3a3..59ef40af 100644 --- a/bindings/python/notmuch/messages.py +++ b/bindings/python/notmuch/messages.py @@ -172,11 +172,15 @@ class Messages(object): next = __next__ # python2.x iterator protocol compatibility def __nonzero__(self): - """ - :return: True if there is at least one more thread in the - Iterator, False if not.""" - return self._msgs is not None and \ - self._valid(self._msgs) > 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._msgs and self._valid(self._msgs) _destroy = nmlib.notmuch_messages_destroy _destroy.argtypes = [NotmuchMessagesP]