Path: csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.027 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'python:': 0.09; 'way:': 0.09; 'def': 0.12; 'jan': 0.12; '"and"': 0.16; 'be:': 0.16; 'none.': 0.16; 'opposite': 0.16; 'underlying': 0.16; 'wrote:': 0.18; 'wed,': 0.18; '>>>': 0.22; 'error': 0.23; 'header:In-Reply- To:1': 0.27; 'function': 0.29; 'message-id:@mail.gmail.com': 0.30; "d'aprano": 0.31; 'pascal': 0.31; 'steven': 0.31; 'sense': 0.34; 'skip:d 20': 0.34; "i'd": 0.34; 'received:google.com': 0.35; 'really': 0.36; 'false': 0.36; 'returning': 0.36; 'scheme': 0.36; 'example,': 0.37; 'skip:o 20': 0.38; 'depends': 0.38; 'to:addr :python-list': 0.38; 'pm,': 0.38; 'rather': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'first': 0.61; 'skip:n 10': 0.64; 'other.': 0.75; '2015': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=1ZHAp66dTesiJ7hMVDtb7puqHFztlyY+sJ7f6mCwylA=; b=NaTiBrBgsZKfY0ecgYlegh7HBTI8q03fqnTB+besWRMZgzEhsxxMtUOk8a5/Hy3l66 Zv4yBws//3Z6IjV65flCFYpVPNUHADcx8dEmTyEi7xiEHJvKoj0Bd62UemmJMRejRqqZ QtCVZWdeoL2+POC0h3jxkzvuIXi480R5VAmlx2PbiMo/DFtNA5gEv5ACjtad/DIPmoN6 GmZyrnKNmvIGOeXarEH++/jmJrxjBmave48+7CDYCAxBTDUz58VMdrhgl0kYwu6g6mvj 4dlr6pSyyjkF0YqyCgMcKt4doNnoSz+CUV/m9URZ7fACxsVe0POw9KphPBloZOjtMvqj +zNw== X-Received: by 10.68.222.130 with SMTP id qm2mr15872545pbc.44.1420729083952; Thu, 08 Jan 2015 06:58:03 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <877fwx3i8f.fsf@elektro.pacujo.net> References: <54ABB88A.7070504@r3dsolutions.com> <54ABC52A.1050507@davea.name> <54ABE383.3020801@r3dsolutions.com> <54ABEAD9.8070000@davea.name> <54ace9f0$0$2738$c3e8da3$76491128@news.astraweb.com> <87tx02gb9d.fsf@elektro.pacujo.net> <54adc53c$0$12999$c3e8da3$5496439d@news.astraweb.com> <877fwx3i8f.fsf@elektro.pacujo.net> From: Ian Kelly Date: Thu, 8 Jan 2015 07:57:23 -0700 Subject: Re: Comparisons and sorting of a numeric class.... To: Python 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: 42 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1420729591 news.xs4all.nl 2887 [2001:888:2000:d::a6]:51601 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:83345 On Wed, Jan 7, 2015 at 11:21 PM, Marko Rauhamaa wrote: > Steven D'Aprano : > >> Marko Rauhamaa wrote: >>> I prefer the Scheme way: >>> #f is a falsey object >>> everything else is a truthy object >> >> The Scheme way has no underlying model of what truthiness represents, just >> an arbitrary choice to make a single value have one truthiness, and >> everything else the other. It's just as meaningless and just as arbitrary >> as the opposite would be: >> >> #t is True >> everything else is falsey >> [...] >> I'd rather the Pascal way: >> >> #t is True >> #f is False >> everything else is an error > > An advantage of the Scheme way is the chaining of "and" and "or". For > example, this breaks in Python: > > def dir_contents(path): > if os.path.isdir(path): > return os.listdir(path) > return None > > def get_choices(): > return dir_contents(PRIMARY) or \ > dir_contents(SECONDARY) or \ > [ BUILTIN_PATH ] That depends on what the function is intended to do in the first place. Why would you want to return the contents of an empty directory rather than the default? Anyway, to make that work as you want it in Scheme, dir_contents would have to return #f, not None. Does it really make sense for a non-predicate function to be returning the value "false"?