Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Denis McMahon Newsgroups: comp.lang.python Subject: Re: Truthiness Date: Thu, 23 Oct 2014 16:07:14 +0000 (UTC) Organization: A noiseless patient Spider Lines: 19 Message-ID: References: <61f0b04c-b827-4c03-b55d-4d5bd85b56f6@googlegroups.com> <87bnp23ksg.fsf@dpt-info.u-strasbg.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Thu, 23 Oct 2014 16:07:14 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="66ffcfa4470a58bcddbdcd1913f98ab4"; logging-data="30736"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+1FmzDPgQs4T9VxqfqcG4EFfz/ZQvp4qU=" User-Agent: Pan/0.136 (I'm far too busy being delicious; GIT 926a150 git://git.gnome.org/pan2) Cancel-Lock: sha1:kC48MyBgfxMT98I/Q0RGJdSk5nc= Xref: csiph.com comp.lang.python:79539 On Thu, 23 Oct 2014 16:47:27 +0200, Alain Ketterlin wrote: > says: "In the context of Boolean operations, and also when expressions > are used by control flow statements, the following values are > interpreted as false: False, None, numeric zero of all types, and empty > strings and containers (including strings, tuples, lists, dictionaries, > sets and frozensets). All other values are interpreted as true." Yep, and I expect this to bite S4H shortly, when he can't understand why the following are not all of the same truthiness: 0 (falsey - numeric 0) [] (falsey - empty set) "" (falsey - empty string) [""] (truthy - non empty set) [0] (truthy - non empty set) -- Denis McMahon, denismfmcmahon@gmail.com