]> git.notmuchmail.org Git - notmuch/blobdiff - bindings/python/notmuch/threads.py
version: bump to 0.15.1
[notmuch] / bindings / python / notmuch / threads.py
index a6441640605b13bf909d8a7e77c5cc609e98718a..f8ca34a9b14cc0f801a019848d4177a836cfc1a0 100644 (file)
@@ -17,7 +17,7 @@ along with notmuch.  If not, see <http://www.gnu.org/licenses/>.
 Copyright 2010 Sebastian Spaeth <Sebastian@SSpaeth.de>
 """
 
-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
-
-        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]