On Thu, Jun 5, 2008 at 3:35 PM, Tino Wildenhain <[EMAIL PROTECTED]> wrote: > Hi, > > Marco Bizzarri wrote: > ... >>> >>> if result: >>> result_len = results.actual_result_count >>> else: >>> result_len = 0 >>> >>> return result_len >>> > ... >> >> Thanks for your answer, but there is something I do not understand: >> >> if results: >> >> an empty result from ZCatlog is false in a boolen condition? > > Yes, thats standard Python behavior, empty lists, dictionaries > and similar objects are assumed "False" when used as boolean. > > This means you could even write it this way: > > return (results and results.actual_result_count) or 0 > > in python2.5 (not yet supported by Zope) even: > > return results.actual_result_count if results else 0 > > Cheers > Tino > >
Tino, Janko, thanks for the clarification. I understand the standard behaviour of list and tuples. But what a Catalog returns is not (if I understand it correctly) a list or a tuple, even though it presents as such. It is a subclass of Lazy. Is Lazy behaving like a list or a tuple, in this respect? Regards Marco -- Marco Bizzarri http://iliveinpisa.blogspot.com/ _______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )