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


Groups > comp.lang.python > #83666

Re: Comparisons and sorting of a numeric class....

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.006
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'scripts': 0.03; 'syntax': 0.04; 'guido': 0.05; 'assign': 0.07; 'python': 0.11; 'def': 0.12; 'jan': 0.12; 'backward': 0.16; 'bool': 0.16; 'emulation': 0.16; 'subclassing': 0.16; 'syntaxerror:': 0.16; 'wrote:': 0.18; "python's": 0.19; '>>>': 0.22; '2.x': 0.24; 'replace': 0.24; 'mon,': 0.24; 'posts': 0.26; 'skip:_ 20': 0.27; 'header:In-Reply- To:1': 0.27; 'point': 0.28; 'fixed': 0.29; 'andrew': 0.30; 'forgot': 0.30; 'statement': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; '"",': 0.31; 'assert': 0.31; 'allows': 0.31; 'file': 0.32; 'class': 0.32; 'another': 0.32; 'skip:_ 10': 0.34; "can't": 0.35; 'test': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'false': 0.36; 'keyword': 0.36; 'skip:[ 10': 0.38; 'to:addr :python-list': 0.38; 'pm,': 0.38; '12,': 0.39; 'to:addr:python.org': 0.39; 'even': 0.60; 'tell': 0.60; 'making': 0.63; 'between': 0.67; 'invalid': 0.68; '2015': 0.84; 'hypothesis': 0.84; 'bears': 0.91
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=FbzIL4yr2Fm5eWwgzQReeGxqrxKxIYxGKZFvHCKv/ys=; b=kV3JUh4dvdz9vBuZkxfXv2zrJEwGCr5Gzl8TAs/3ZIYjgaxWdksyRrw/C2fVb0It7b CEGHRzWoAyN9VhmCJTBoKoYWSpKx4s/VroWHoDckpeH9zQWlZYh6SUwWxW3dJ7EdTuBG 3qkBHBpKWJYoXy/AX8RfkIhSBaxnbiXn4WKtMvVyxoT0tPZpjraavTr50ml745pl17mT qYGbaHutim+eYtU/Wt6SSEHcQn3hBc2BCEHYek6dwRLCHBwdHJyMqIbUSw34tNZwG/IO z7Tt65kt8cv1+2QbdShA7ih0iKDP6bJ3SPdturrd2ynGYLnomWIGADf8nBi7CKq6T7dg 4jKw==
X-Received by 10.67.13.12 with SMTP id eu12mr49872876pad.157.1421130210856; Mon, 12 Jan 2015 22:23:30 -0800 (PST)
MIME-Version 1.0
In-Reply-To <54B49C34.6050900@r3dsolutions.com>
References <54ABB88A.7070504@r3dsolutions.com> <54ABC52A.1050507@davea.name> <54ABE383.3020801@r3dsolutions.com> <CAPTjJmpktyHfghEr+cjPrhso7JgB4VfS4=5Gdi95gT0aFbSYGA@mail.gmail.com> <54AC97D9.4010504@r3dsolutions.com> <CAPTjJmooTK_+HVoeyeSrqBHN1=YjRYQ2kfDyQtL9JoA9SbTqsQ@mail.gmail.com> <54ACAA04.60801@r3dsolutions.com> <54ADC99F.3020405@stoneleaf.us> <54B44A64.7010105@r3dsolutions.com> <CAPTjJmr0Bqcyj=VBADVSthSZ+pYMXQeNC-j8qLC2xHAVLUmcgA@mail.gmail.com> <54B47C0E.208@r3dsolutions.com> <CAPTjJmpX-Y++Uv=pMT6xVTpPk5-dkJd6BwUD0RFqLtON4XRm=Q@mail.gmail.com> <54B49C34.6050900@r3dsolutions.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Mon, 12 Jan 2015 23:22:50 -0700
Subject Re: Comparisons and sorting of a numeric class....
To Python <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 <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.17660.1421130220.18130.python-list@python.org> (permalink)
Lines 37
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1421130220 news.xs4all.nl 2919 [2001:888:2000:d::a6]:35682
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:83666

Show key headers only | View raw


On Mon, Jan 12, 2015 at 9:16 PM, Andrew Robinson
<andrew3@r3dsolutions.com> wrote:
> Instead of pretending what if -- let's actually REPLACE python's built in
> bool class with an emulation that ALLOWS subclassing and THEN let's TEST my
> hypothesis that the assert statement you gave me can't tell the difference
> between bools any anthing else by it's actions...  ( ooooh ... another
> back-door that Guido forgot about... or perhaps purposely left open...)
>
> class bool( int ):
>     def __new__(self,data): return super( bool, self).__new__(self,
> [0,1][data!=0] )
>     def __repr__(self): return [ 'True', 'False' ][self>0]
>
> __builtins__.bool=bool
> __builtins__.True=bool( 1==1 )
> __builtins__.False=bool( 1==0 )

Your posts are so wordy that I'm not even going to try to respond to
all of them, but this is an interesting point that bears explanation.
The reason you can reassign True and False in Python 2.x is for
backward compatibility with scripts that predated the built-in bool
type and would do things like:

True = 1
False = 0

However, this longstanding wart was fixed in Python 3 by making True
and False keywords:

>>> True = 42
  File "<stdin>", line 1
SyntaxError: can't assign to keyword
>>> __builtins__.True = 42
  File "<stdin>", line 1
    __builtins__.True = 42
                    ^
SyntaxError: invalid syntax

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


Thread

Re: Comparisons and sorting of a numeric class.... Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-12 23:22 -0700

csiph-web