unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* python: unpythonic result of Message.get_replies()
@ 2011-10-05  1:42 Justus Winter
  2011-11-02  7:29 ` Sebastian Spaeth
  0 siblings, 1 reply; 9+ messages in thread
From: Justus Winter @ 2011-10-05  1:42 UTC (permalink / raw)
  To: notmuch

[-- Attachment #1: Type: text/plain, Size: 816 bytes --]


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

[-- Attachment #2: .signature --]
[-- Type: application/octet-stream, Size: 17 bytes --]

love u alot @,@


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-01-02 16:03 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-05  1:42 python: unpythonic result of Message.get_replies() Justus Winter
2011-11-02  7:29 ` Sebastian Spaeth
2011-12-21 13:15   ` Justus Winter
2011-12-21 13:15     ` [PATCH 1/2] python: refactor print_messages into format_messages and print_messages Justus Winter
2012-01-02 13:13       ` Tomi Ollila
2012-01-02 15:56       ` Sebastian Spaeth
2011-12-21 13:15     ` [PATCH 2/2] python: make the result of Message.get_replies() more pythonic Justus Winter
2012-01-02 13:15       ` Tomi Ollila
2012-01-02 16:03       ` Sebastian Spaeth

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).