Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1.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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python,': 0.02; 'algorithm': 0.04; 'plenty': 0.07; 'python:': 0.09; 'way:': 0.09; 'def': 0.12; 'jan': 0.12; '"and"': 0.16; '>>': 0.16; 'acted': 0.16; 'be:': 0.16; 'merely': 0.16; 'none.': 0.16; 'opposite': 0.16; 'tables,': 0.16; 'underlying': 0.16; 'wished': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'bit': 0.19; 'thu,': 0.19; '>>>': 0.22; 'email addr:gmail.com>': 0.22; 'previously': 0.22; 'error': 0.23; '>>>': 0.24; "i've": 0.25; '>': 0.26; 'second': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; "d'aprano": 0.31; 'pascal': 0.31; 'steven': 0.31; 'this.': 0.32; 'quite': 0.32; 'sense': 0.34; 'skip:d 20': 0.34; "i'd": 0.34; 'received:74.125.82': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'false': 0.36; 'returning': 0.36; 'scheme': 0.36; 'doing': 0.36; 'example,': 0.37; 'skip:o 20': 0.38; 'skip:& 10': 0.38; 'depends': 0.38; 'to:addr:python- list': 0.38; 'pm,': 0.38; 'rather': 0.38; 'received:74.125': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'ian': 0.60; 'first': 0.61; 'times': 0.62; 'skip:n 10': 0.64; 'believe': 0.68; 'superior': 0.69; 'other.': 0.75; '2015': 0.84; 'lately,': 0.84 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type; bh=eaWm7yUouEekvLobuirLOuwGOY+GFZCl/WXeYILN+ys=; b=Q0DYKvsTZoSj6XNgyKq9KrJmID18pRDJ5Nw6kzJ4XyFVypR2/wu72h0AHTPGRlZkHw r93uAVqpgBphCMUEiVb1gdilZrEO9/QtlcOX6rtC/n77cW00vOdBsh4U402oOtubV4ES CMBDz97wGiWi1C128Wb80w6sdSUxq7PDnmh6ZKDYs5rh83ytmcY030yHKGNuHMk7WnP2 Amfv3Ijg6NcGAwwnESndnij9xIRgsc79x+OD5VtH8/9APZ45S0m2tzcX8sBWLSaUqu/B Q2QVGADDSbJrEfYKulhB0KoQUev6qkpnKam/cTd8FV0kaHJ4GRMsLoj66GJ8jq20d0D1 ZkCA== X-Gm-Message-State: ALoCoQknJAUhPiUX1W5CZTOnYOqM1AM1TcD20a5fZTpOJIyNOP2UEvKLcvWtkUeZKDQsiT7sU/j0 X-Received: by 10.180.109.3 with SMTP id ho3mr63349151wib.39.1420742699194; Thu, 08 Jan 2015 10:44:59 -0800 (PST) MIME-Version: 1.0 In-Reply-To: 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: Chris Kaynor Date: Thu, 8 Jan 2015 10:44:39 -0800 Subject: Re: Comparisons and sorting of a numeric class.... To: Python Content-Type: multipart/alternative; boundary=e89a8f3b9dafe72e3b050c286fd5 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: 128 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1420742711 news.xs4all.nl 2970 [2001:888:2000:d::a6]:59803 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:83363 --e89a8f3b9dafe72e3b050c286fd5 Content-Type: text/plain; charset=UTF-8 On Thu, Jan 8, 2015 at 6:57 AM, Ian Kelly wrote: > 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"? I'd like to second this. I don't believe either way is inherently superior to the other. Lately, I've been doing quite a bit of work in lua, and many times have wished that empty strings, tables, and 0 acted "falsey", but at the same time, previously working in Python, there were plenty of times I wished they acted "truthy". It merely depends on what algorithm I am using at the time... --e89a8f3b9dafe72e3b050c286fd5 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On T= hu, Jan 8, 2015 at 6:57 AM, Ian Kelly <ian.g.kelly@gmail.com> wrote:
On Wed, Jan 7, 2015 at 11:21 PM, Marko Rauhamaa <marko@pacujo.net> wrote:
> Steven D'Aprano <steve+comp.lang.python@pearwood.info>:
>
>> Marko Rauhamaa wrote:
>>> I prefer the Scheme way:
>>>=C2=A0 =C2=A0 #f is a falsey object
>>>=C2=A0 =C2=A0 everything else is a truthy object
>>
>> The Scheme way has no underlying model of what truthiness represen= ts, just
>> an arbitrary choice to make a single value have one truthiness, an= d
>> everything else the other. It's just as meaningless and just a= s arbitrary
>> as the opposite would be:
>>
>>=C2=A0 =C2=A0 =C2=A0#t is True
>>=C2=A0 =C2=A0 =C2=A0everything else is falsey
>> [...]
>> I'd rather the Pascal way:
>>
>>=C2=A0 =C2=A0 =C2=A0#t is True
>>=C2=A0 =C2=A0 =C2=A0#f is False
>>=C2=A0 =C2=A0 =C2=A0everything else is an error
>
> An advantage of the Scheme way is the chaining of "and" and = "or". For
> example, this breaks in Python:
>
>=C2=A0 =C2=A0 def dir_contents(path):
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 if os.path.isdir(path):
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return os.listdir(path)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 return None
>
>=C2=A0 =C2=A0 def get_choices():
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 return dir_contents(PRIMARY) or \
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 dir_contents(SECONDARY) or \<= br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 [ BUILTIN_PATH ]

That depends on what the function is intended to do in the firs= t
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"?

I'd like to second this. I don't believe e= ither way is inherently superior to the other.

Lat= ely, I've been doing quite a bit of work in lua, and many times have wi= shed that empty strings, tables, and 0 acted "falsey", but at the= same time, previously working in Python, there were plenty of times I wish= ed they acted "truthy". It merely depends on what algorithm I am = using at the time...

--e89a8f3b9dafe72e3b050c286fd5--