<div class="gmail_quote">On 2 June 2011 17:05, Sebastian Spaeth <span dir="ltr"><<a href="mailto:Sebastian@sspaeth.de">Sebastian@sspaeth.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">What would be the best way to solve this (besides fixing the C api to</div>
allow to reset the iterator ;-) ?)<br><br></blockquote><div><br></div><div> I am not really familiar with the code. So am I correct in making the following assumptions?</div><div><br></div><div>* It is not easy to fix the C api to reset the iterator (what about repeating the search?)</div>
<div><br></div><div>* The only accurate way to get the number of messages is to iterate through every search result and count them?</div><div><br></div><div>If so, then len(...) I think might be very slow if there are a large number of elements.</div>
<div><br></div><div>Maybe it might be easier/better to implement object.__nonzero__(self) instead of the object.__len__(self) method?</div><div><br></div><div><a href="http://docs.python.org/reference/datamodel.html">http://docs.python.org/reference/datamodel.html</a></div>
<div><br></div><div><div>object.__nonzero__(self)</div><div>Called to implement truth value testing and the built-in operation bool(); should return False or True, or their integer equivalents 0 or 1. When this method is not defined, __len__() is called, if it is defined, and the object is considered true if its result is nonzero. If a class defines neither __len__() nor __nonzero__(), all its instances are considered true.</div>
<div><br></div><div><div>object.__len__(self)</div><div>Called to implement the built-in function len(). Should return the length of the object, an integer >= 0. Also, an object that doesn’t define a __nonzero__() method and whose __len__() method returns zero is considered to be false in a Boolean context.</div>
</div></div><div><br></div></div>-- <br>Brian May <<a href="mailto:brian@microcomaustralia.com.au">brian@microcomaustralia.com.au</a>><br>