Why does list have no 'get' method?

Thomas Bellman bellman at lysator.liu.se
Thu Feb 7 12:06:45 CET 2008

Bruno Desthuilliers <bruno.42.desthuilliers at wtf.websiteburo.oops.com> wrote:

> Not quite. In C and a couple other langages, int 0 is false, anything 
> else is true.

Not just int, but all kinds of integers, as well as all kinds of
floating point types and all kinds of pointers, with the value 0
are considered false.  And structs and unions can't be used in a
boolean context at all, and are thus neither true nor false.

>               In Lisp (and IIRC), an empty list is false, anything else 
> is true.

There seems to be a language name missing from the parenthesis.
Were you perhaps thinking of Scheme?  If so, then no, in Scheme
only #f is false, and the empty list () is considered true.

Thomas Bellman,   Lysator Computer Club,   Linköping University,  Sweden
"When C++ is your hammer, everything         !  bellman @ lysator.liu.se
 looks like a thumb."                        !  Make Love -- Nicht Wahr!

More information about the Python-list mailing list