]> git.notmuchmail.org Git - notmuch/commit
bindings/python: Implement Tags().__nonzero__()
authorSebastian Spaeth <Sebastian@SSpaeth.de>
Thu, 2 Jun 2011 15:28:50 +0000 (17:28 +0200)
committerSebastian Spaeth <Sebastian@SSpaeth.de>
Thu, 2 Jun 2011 15:28:50 +0000 (17:28 +0200)
commitaeecafa694e8296411ad21cee1b7de094600babf
tree37cc6a6f95cc3fd4adb1adfc4e1949527dbbc2cb
parent01cc4a31155dc71643fce1b619778493c1ff0dd7
bindings/python: Implement Tags().__nonzero__()

Analog to Threads.__nonzero__ this allows us to perform list() on a Threads() object and to repeatedly call "if Tags():" or "bool(Tags())" without implicitly invoking len(), thus exhausting our iterator.

While touching this code, I added a small micro-optimization to the Tag next() function. There is no need to explicitly check _is_valid, as _get implicitly does check for validness and returns None, if there is no more Tag to fetch. This avoids some roundtrips into the library when iterating through Tags.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
bindings/python/notmuch/tag.py