python: unpythonic result of Message.get_replies()

Justus Winter 4winter at informatik.uni-hamburg.de
Tue Oct 4 18:42:38 PDT 2011


Hi everyone :)

I noticed that Message.get_replies() returns a Messages object *or*
None. Quoting the documentation:

> Returns: Messages or None if there are no replies to this message

Messages is a class implementing the iterator protocol, so a python
programmer would expect to get an iterator that raises a StopIteration
on the first invocation of next() if there aren't any replies.

With the current implementation one needs to do something like

replies = message.get_replies()
if replies != None:
    for reply in replies:
        [...]

which looks awkward. Imho one should be able to just do

for reply in message.get_replies():
    [...]

What do you think? Would it be possible to get this into the 0.9
release? I could propose a patch if you like, but not today...

Justus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .signature
Type: application/octet-stream
Size: 17 bytes
Desc: not available
URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20111005/ab0fbc26/attachment.obj>


More information about the notmuch mailing list