python: unpythonic result of Message.get_replies()

2011-12-21 Thread Justus Winter
The attached patch series fixes this problem. Note that the wrapping
nature of the notmuch bindings makes it kind of awkward to fix the
behavior.

I've decided to avoid introducing code to the Messages class to
indicate that there are no messages and there is no notmuch object
being wrapped, but to subclass it and change the constructor and
__next__ function.

Well, what do you think?
Justus


Re: python: unpythonic result of Message.get_replies()

2011-12-21 Thread Justus Winter
The attached patch series fixes this problem. Note that the wrapping
nature of the notmuch bindings makes it kind of awkward to fix the
behavior.

I've decided to avoid introducing code to the Messages class to
indicate that there are no messages and there is no notmuch object
being wrapped, but to subclass it and change the constructor and
__next__ function.

Well, what do you think?
Justus
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


python: unpythonic result of Message.get_replies()

2011-11-02 Thread Sebastian Spaeth
On Wed, 05 Oct 2011 03:42:38 +0200, Justus Winter <4winter at 
informatik.uni-hamburg.de> wrote:
Non-text part: multipart/mixed
> 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.
> 

Yes, that change would make perfect sense, and I would be happy to
accept a patch for it :-)

Sebastian
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 



Re: python: unpythonic result of Message.get_replies()

2011-11-02 Thread Sebastian Spaeth
On Wed, 05 Oct 2011 03:42:38 +0200, Justus Winter 
4win...@informatik.uni-hamburg.de wrote:
Non-text part: multipart/mixed
 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.
 

Yes, that change would make perfect sense, and I would be happy to
accept a patch for it :-)

Sebastian


pgpVRtwlViqza.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


python: unpythonic result of Message.get_replies()

2011-10-05 Thread Justus Winter

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: 



python: unpythonic result of Message.get_replies()

2011-10-04 Thread Justus Winter

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


.signature
Description: Binary data
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch