aboutsummaryrefslogtreecommitdiff
path: root/bindings/python/notmuch/messages.py
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2012-04-30 19:12:36 +0200
committerJustus Winter <4winter@informatik.uni-hamburg.de>2012-04-30 19:25:16 +0200
commit7f74a400d197dac5cdf36960f68f63ce3eeff486 (patch)
tree9dcedef71864d1bd683e3fda85ee13b80a2deed2 /bindings/python/notmuch/messages.py
parent162687a99e412098729d639ed7bc27f01372cb84 (diff)
python: cleanup the __nonzero__ implementations
Cleanup the code, reword the docstring and use the same implementation in the Threads, Tags and Messages classes. __nonzero__ implements truth value testing. If __nonzero__ is not implemented, the python runtime would fall back to `len(..) > 0` thus exhausting the iterator. Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
Diffstat (limited to 'bindings/python/notmuch/messages.py')
-rw-r--r--bindings/python/notmuch/messages.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/bindings/python/notmuch/messages.py b/bindings/python/notmuch/messages.py
index 251fa3a..59ef40a 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]