unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Justus Winter <4winter@informatik.uni-hamburg.de>
To: notmuch@notmuchmail.org
Subject: python: unpythonic result of Message.get_replies()
Date: Wed, 05 Oct 2011 03:42:38 +0200	[thread overview]
Message-ID: <E1RBGVK-0000Xu-Pc@thinkbox.jade-hamburg.de> (raw)

[-- 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 @,@


             reply	other threads:[~2011-10-05  1:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-05  1:42 Justus Winter [this message]
2011-11-02  7:29 ` python: unpythonic result of Message.get_replies() 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1RBGVK-0000Xu-Pc@thinkbox.jade-hamburg.de \
    --to=4winter@informatik.uni-hamburg.de \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).