Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #17147

boolean from a function

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.chainon-marquant.org!news-transit.tcx.org.uk!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <andrea.crotti.0@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.045
X-Spam-Evidence '*H*': 0.91; '*S*': 0.00; 'else:': 0.03; 'bug,': 0.09; 'def': 0.13; 'boolean': 0.16; 'subject:function': 0.16; 'warn': 0.16; '(or': 0.22; "doesn't": 0.22; 'somewhere': 0.23; 'noticed': 0.24; "i'm": 0.26; 'function': 0.27; 'true,': 0.29; 'quite': 0.32; 'received:209.85.161.46': 0.32; 'received:mail- fx0-f46.google.com': 0.32; 'message-id:@gmail.com': 0.33; 'header :User-Agent:1': 0.33; 'instead': 0.33; 'there': 0.33; 'to:addr :python-list': 0.34; 'something': 0.35; 'problem.': 0.36; 'received:209.85.161': 0.36; 'received:google.com': 0.37; 'think': 0.37; 'could': 0.37; 'received:10.0.0': 0.38; 'some': 0.38; 'received:209.85': 0.38; 'subject:from': 0.38; 'else': 0.39; 'tool': 0.39; 'why': 0.39; 'received:209': 0.40; 'to:addr:python.org': 0.40; 'ever': 0.65; 'that)': 0.84; 'stupid': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; bh=cOhOuTwkLoZ2i0N1v0lPv0l0Ru2zIGHDEzoTdCNbZ30=; b=FKiZct1cwB3TfExQaepJ0czNEfej4ACMIBq+4x9+cHW/CKoYDnbP0uyDu7bCF+0e2/ gPdkNXyzVoEqNZMGpuAphDHQb0R/NnMgQRqrqc0DBn2VbFlvgGswxrbIIGUtUC6s49vV CUpU9VEQtDGsO7+h3K2PRl1hE7lgEpDJh42W4=
Date Tue, 13 Dec 2011 16:24:05 +0000
From Andrea Crotti <andrea.crotti.0@gmail.com>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20111108 Thunderbird/8.0
MIME-Version 1.0
To python-list@python.org
Subject boolean from a function
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3604.1323793451.27778.python-list@python.org> (permalink)
Lines 21
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1323793451 news.xs4all.nl 6989 [2001:888:2000:d::a6]:55828
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:17147

Show key headers only | View raw


I'm not sure for how long I had this bug, and I could not understand the 
problem.

I had a function which would return a boolean

def func_bool():
     if x:
         return True
     else: return False

Now somewhere else I had

if func_bool:
     # do something

I could not quite understand why it was always true, until I finally noticed
that the () were missing.
Is there some tool to avoid these stupid mistakes? (pylint doesn't warn 
me on that)
I don't think I will ever (or almost) have to use a function as a 
boolean, instead of its return value...

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

boolean from a function Andrea Crotti <andrea.crotti.0@gmail.com> - 2011-12-13 16:24 +0000
  Re: boolean from a function Grant Edwards <invalid@invalid.invalid> - 2011-12-13 17:20 +0000
  Re: boolean from a function Duncan Booth <duncan.booth@invalid.invalid> - 2011-12-13 17:42 +0000
  Re: boolean from a function Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-13 23:37 +0000
    Re: boolean from a function Andrea Crotti <andrea.crotti.0@gmail.com> - 2011-12-14 09:42 +0000

csiph-web