Brett Hoerner wrote: > [EMAIL PROTECTED] wrote: [...] > "or" returns the first true element, anything but False or None, I > think... so 'food' (a string) is true, and always will return in that > code.
Just in case newbies are reading: in Python several different values are considered false in the context of an "if" statement. These include False # Boolean False 0 # The integer zero 0.0 # Floating-point zero (0+0j) # Complex zero None # The None object [] # The empty list () # The empty tuple {} # The empty dictionary This is mainly to allow the convenience of writing if thing: ... However, one has to be careful that code that needs to treat None differently from [] uses explicit testing such as if thing is None: ... You can also construct your own classes so their instances evaluate to True or False according to your needs. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC www.holdenweb.com PyCon TX 2006 www.python.org/pycon/ -- http://mail.python.org/mailman/listinfo/python-list