X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=bindings%2Fpython%2Fnotmuch%2Fthreads.py;h=f8ca34a9b14cc0f801a019848d4177a836cfc1a0;hb=acb079e35726cc421b6a314ab4f26d5eb92feaf1;hp=fb053f939de64ca42b968571ab56a68fc0e36ec3;hpb=1f08664a6b8f7cba63f63855833f877b66bbbe05;p=notmuch diff --git a/bindings/python/notmuch/threads.py b/bindings/python/notmuch/threads.py index fb053f93..f8ca34a9 100644 --- a/bindings/python/notmuch/threads.py +++ b/bindings/python/notmuch/threads.py @@ -17,7 +17,7 @@ along with notmuch. If not, see . Copyright 2010 Sebastian Spaeth """ -from notmuch.globals import ( +from .globals import ( nmlib, Python3StringMixIn, NotmuchThreadP, @@ -157,18 +157,15 @@ class Threads(Python3StringMixIn): return i def __nonzero__(self): - """Check if :class:`Threads` contains at least one more valid thread + ''' + Implement truth value testing. If __nonzero__ is not + implemented, the python runtime would fall back to `len(..) > + 0` thus exhausting the iterator. - 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 + :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] @@ -176,5 +173,5 @@ class Threads(Python3StringMixIn): def __del__(self): """Close and free the notmuch Threads""" - if self._threads is not None: + if self._threads: self._destroy(self._threads)