Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.012 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'explicit': 0.07; 'mess': 0.09; 'subject:test': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'wrote': 0.14; '12:04': 0.16; 'basic.': 0.16; 'consciously': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'language': 0.16; 'wrote:': 0.18; 'basically': 0.19; 'code,': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'days,': 0.24; 'cc:2**0': 0.24; 'sort': 0.25; 'this:': 0.26; 'read,': 0.26; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'michael': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; 'getting': 0.31; 'lines': 0.31; 'run': 0.32; 'trouble': 0.34; "i'd": 0.34; 'basic': 0.35; 'common': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'limitations': 0.36; 'pm,': 0.38; "couldn't": 0.39; 'read': 0.60; 'most': 0.60; 'back': 0.62; '26,': 0.68; 'idiom': 0.84; 'thing...': 0.84; 'subject::': 0.85; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=+I1cDQ34+MFY0p7ockydH3DzhLJsprbeFWZgOmqagHs=; b=RGXAwmtZNHi8Rz7qCUzzw4TYqxPvMkusRMGrmFG5NBZ279PTV1GVkSKJ32nyLbcGO9 J5XstOL4DzRCmurR/oiKASdXB+2niSuKcq+fIwN/hK8/C+XBoOemA4cQCUsqSlZa2V95 YS3zFCh3IAB5ybSeHxbjG7CLJlt9uqWuT6F5SOPCGfTAvo35I0+8RGlQm3l1Xh+UxlTV 666PxtrvpfzxH7eBf5oCRzy+2ARFzywRhMXiyzbNSeO4k2k/MFRsD/hvqFkj5Lf3tb4c pBgnMmaAM48Sxa9t2LUGY9gOWj0TwF7Qavga2b/u8evUygl2qbOf8XR5k2OfpR7srgj4 KD5Q== MIME-Version: 1.0 X-Received: by 10.107.172.210 with SMTP id v201mr13355620ioe.19.1414286404421; Sat, 25 Oct 2014 18:20:04 -0700 (PDT) In-Reply-To: <544C48B4.6020107@gmail.com> References: <54476af8$0$21651$426a74cc@news.free.fr> <7839376e-fc27-4299-ae63-4ddf17ef9a8a@googlegroups.com> <544C48B4.6020107@gmail.com> Date: Sun, 26 Oct 2014 12:20:04 +1100 Subject: Re: (test) ? a:b From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 24 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1414286413 news.xs4all.nl 2955 [2001:888:2000:d::a6]:39320 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:79700 On Sun, Oct 26, 2014 at 12:04 PM, Michael Torrie wrote: > But you can run > into trouble if you tried to use a common python idiom like this: > > x = read_some_lines() 'returns number of lines read, or zero if none are > if not x: > print ("I couldn't read any lines") > exit(1) > > Basically any value other than -1 for x would cause the not x to be > true. So don't use Python idioms in BASIC. :) Back when I used to write BASIC code, I'd do explicit comparisons with zero for this sort of thing... these days, I'd use Python idioms, but I'd also write Python code :) I think it's indicative that the BASIC code I'm most proud of was consciously getting around language limitations (I wrote a mess of code in assembly language and Q-BASIC to allow my programs to use the mouse), but the Python code I'm most proud of is using the language's strengths. ChrisA