I agre that in the 'a' and 'b' case it's not so much a question of logic as it is value representation. I included it in the discussion because I thought it was interesting. Also, the page I linked to had a definition of Python's true / false: 0, '', [], (), {}, and None are false in a boolean context; everything else is true PS. I have actually used the 'and-or trick' once or twice after I found out about this -----Original Message----- From: Eron Lloyd [mailto:elloyd@lancaster.lib.pa.us] Sent: Thursday, 5 September 2002 10:55 a.m. To: Chris Beaven Cc: Brian Sullivan; zope@zope.org Subject: RE: [Zope] Boolean properties ( Zope 2.5) Correct, but that's only when doing a comparison. Python will perform a lazy comparison, returning either the first true value (in an "or" expr.), or the last true value in an "and" expr. In the case stated, it's not so much a question of logic as it is value representation. Honestly, I don't understand why you would ever want the actual *value* returned by a boolean expression, instead of it's state. What needs to be done probably is a re-examination of the problem at hand. Cheers, Eron On Wed, 2002-09-04 at 18:29, Chris Beaven wrote:
In Python, 'and' and 'or' perform boolean logic as you would expect, but they do not return boolean values; they return one of the actual values they are comparing.
'a' and 'b' 'b' '' and 'b' ''
'a' or 'b' 'a' '' or 'b' 'b'
http://diveintopython.org/apihelper_andor.html
Well, I found it interesting...
-----Original Message----- From: Brian Sullivan [mailto:brians@meetingbywire.com] Sent: Thursday, 5 September 2002 2:27 a.m. To: zope@zope.org Subject: [Zope] Boolean properties ( Zope 2.5)
I a trying to figure out what values are stored in Boolean typed properties of a Zope object in order to display information in and retrieve and set information from form checkboxes.
What values are actually set/returned in boolean properties?
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev ) --- [This E-mail scanned for viruses by Declude Virus]
--- [This E-mail scanned for viruses by Declude Virus]