help on ultra newbie program please

Erik Max Francis max at alcyone.com
Wed May 21 15:33:38 EDT 2003


cybernut wrote:

> What does that mean? if something == , != ect. something: makes sense
> to me,
> but is that some kind of shortcut ...

if (and other condition-testing structures) just tests whether or not
the expression is "true."  In Python, everything is considered true
except None, False, numeric zeroes, empty builtin container types
(strings, tuples, lists, dictionaries, etc.), and custom types which
override their __nonzero__ or __len__ methods appropriately:

	http://www.python.org/doc/current/lib/truth.html#l2h-78

	if x == y: ...

is simply a special case of this, because the expression (x == y)
returns a value which is considered true if x equals y, and one
considered false otherwise.

-- 
   Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
 __ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/  \ People say that life is the thing, but I prefer reading.
\__/  Logan Pearsall Smith




More information about the Python-list mailing list