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


Groups > comp.lang.python > #84628

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

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; '"this': 0.03; '(at': 0.04; 'resulting': 0.04; 'explicitly': 0.05; 'see:': 0.07; 'yeah,': 0.09; 'python': 0.11; 'jan': 0.12; 'wrote': 0.14; 'aggressively': 0.16; 'bool': 0.16; 'boolean': 0.16; 'centered': 0.16; 'complained': 0.16; 'composition.': 0.16; 'needless': 0.16; 'operators,': 0.16; 'pythonic': 0.16; 'respond.': 0.16; 'subclass': 0.16; 'subclassing': 0.16; 'thread,': 0.16; 'tuple': 0.16; 'tuple,': 0.16; 'tuple.': 0.16; 'wrote:': 0.18; 'value.': 0.19; 'seems': 0.21; '>>>': 0.22; 'code,': 0.22; 'example': 0.22; '"you': 0.24; 'mon,': 0.24; 'compare': 0.26; 'suggested': 0.26; 'header:In-Reply-To:1': 0.27; 'wonder': 0.29; 'words': 0.29; "doesn't": 0.30; '(like': 0.30; 'andrew': 0.30; 'forgot': 0.30; 'message-id:@mail.gmail.com': 0.30; 'about.': 0.31; 'comparison': 0.31; 'container': 0.31; 'class': 0.32; 'this.': 0.32; 'moment': 0.34; 'offered': 0.35; 'something': 0.35; 'operations': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'i.e.': 0.36; 'object,': 0.36; 'done': 0.36; 'next': 0.36; "didn't": 0.36; "i'll": 0.36; 'should': 0.36; 'example,': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'rather': 0.38; 'to:addr:python.org': 0.39; 'ian': 0.60; 'mentioned': 0.61; 'no.': 0.61; 'skip:* 10': 0.61; 'first': 0.61; 'making': 0.63; 'name': 0.63; 'different': 0.65; 'effectively': 0.66; 'here': 0.66; '26,': 0.68; 'fact,': 0.69; 'click': 0.77; '2015': 0.84; 'good,': 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=yHJpC3iFwYH14CHEYKZLzTK7lh3t24jQD0Cw2V1g9h4=; b=a9u/Vfp5JpQPQ6psOidoMUTc9gthZt3auZoNbg10ze7cWWFKBCmZdYZXLgJdu4G08C 0iuRgmD7Kq/HAbr8IM8W1xtdhgiNuXQEKaJe/0GWsKZRCi2dm/dKYGK6QONuQZmFztb5 UKaww+Y7hrAZ3wqJHaTnNt31BtqtOGLqFHaoDZZxV25bPfRNYNIhBi4n7mtRWwt1BI9V p1bulj2uBOZqvJxOeV9rAmpzLwFPSeNZeV2HW+5FXVpTo9m4ZkDPWB6b1aCiOXGQBvJy WMIKNOYrFdgQxiBLNbxUd7pFr+DxFSNodhfzWMM+8Bx9L5x1niyFLnNuU7jrPNKeR7Sp GjyA==
X-Received by 10.70.95.35 with SMTP id dh3mr38460860pdb.91.1422323449278; Mon, 26 Jan 2015 17:50:49 -0800 (PST)
MIME-Version 1.0
In-Reply-To <54C6D1FD.6070901@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> <mailman.17650.1421114374.18130.python-list@python.org> <54b4aded$0$2738$c3e8da3$76491128@news.astraweb.com> <54B5B486.7080406@r3dsolutions.com> <CALwzidn4t_mVvtUjucKwPLzeq5pgFdYDBLjePMeuEEB7gTvKCQ@mail.gmail.com> <54B72D32.3090209@r3dsolutions.com> <CALwzidmn-WJVMxXmRK=dSw0vWoBLf=rZ-6VhXinQhfn3BjF=TQ@mail.gmail.com> <mailman.17743.1421306724.18130.python-list@python.org> <20150115095452.072d5763@rg.highlandtechnology.com> <54C6D1FD.6070901@r3dsolutions.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Mon, 26 Jan 2015 18:50:07 -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.18162.1422323459.18130.python-list@python.org> (permalink)
Lines 49
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1422323459 news.xs4all.nl 2843 [2001:888:2000:d::a6]:41444
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:84628

Show key headers only | View raw


On Mon, Jan 26, 2015 at 4:47 PM, Andrew Robinson
<andrew3@r3dsolutions.com> wrote:
> Hmmm....  That's not much different than the tuple object I made as a
> container and which Ian complained about.  In fact, you did overload the
> comparison operators, just like I did...

Yeah, I know I said I was done with this thread, but since you call me
out by name I'll take a moment to respond.

> Let's see: Ian first complained that I wasn't subclassing in one example,

No. What I suggested was that for Python 2 you should explicitly name
a base class of object, i.e. the base class of *everything*. That's
not "you should use subclassing here", but rather "here's a tip for
writing good, Pythonic code".

> and then he next complained that he thought I was subclassing  *too quickly*
> (like he forgot that I didn't subclass before) because of something to do
> with 'bool' -- and then he mentioned I wasn't using composition....

I actually wrote about your tuple subclass "This seems fine," so don't
try to spin my words into something that they aren't. My criticism was
centered on your needless subclassing of tuple (nothing to do with
'bool'), resulting in a boolean class that supports nonsensical
operations like:

>>> len(MostlyFalse)
2

and even:

>>> isinstance(MostlyFalse, Sequence)
True

You may also notice that Rob's example which you compare to your own
doesn't do this.

> But now --I wonder why it didn't click with him that I avoided subclassing
> bool in my tuple example (at all)  -- because I was clearly making a general
> purpose container (composition pattern) to hold a bool and uncertainty
> value.

This is not an example of composition. By subclassing tuple, you are
effectively declaring that your boolean type IS a type of tuple.
Instead of aggressively and arrogantly defending poor code, why don't
you take my criticism as the learning opportunity that it was offered
as? Here would be a good place to start:

http://stackoverflow.com/questions/49002/prefer-composition-over-inheritance

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


Thread

Re: Comparisons and sorting of a numeric class.... Andrew Robinson <andrew3@r3dsolutions.com> - 2015-01-12 17:59 -0800
  Re: Comparisons and sorting of a numeric class.... Steven D'Aprano <steve@pearwood.info> - 2015-01-13 05:32 +0000
    Re: Comparisons and sorting of a numeric class.... Chris Angelico <rosuav@gmail.com> - 2015-01-13 17:13 +1100
    Re: Comparisons and sorting of a numeric class.... Terry Reedy <tjreedy@udel.edu> - 2015-01-13 05:49 -0500
      Re: Comparisons and sorting of a numeric class.... Marko Rauhamaa <marko@pacujo.net> - 2015-01-13 13:00 +0200
        Re: Comparisons and sorting of a numeric class.... Chris Angelico <rosuav@gmail.com> - 2015-01-13 22:20 +1100
        Re: Comparisons and sorting of a numeric class.... Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-13 11:56 -0700
        Re: Comparisons and sorting of a numeric class.... Chris Angelico <rosuav@gmail.com> - 2015-01-14 06:02 +1100
    Re: Comparisons and sorting of a numeric class.... Chris Angelico <rosuav@gmail.com> - 2015-01-13 21:56 +1100
    Re: Comparisons and sorting of a numeric class.... Andrew Robinson <andrew3@r3dsolutions.com> - 2015-01-13 16:12 -0800
    Re: Comparisons and sorting of a numeric class.... Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-14 01:31 -0700
    Re: Comparisons and sorting of a numeric class.... Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-14 22:26 -0700
      Re: Comparisons and sorting of a numeric class.... Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2015-01-16 22:23 +1300
    Re: Comparisons and sorting of a numeric class.... Andrew Robinson <andrew3@r3dsolutions.com> - 2015-01-14 23:23 -0800
      Re: Comparisons and sorting of a numeric class.... Steven D'Aprano <steve@pearwood.info> - 2015-01-15 08:41 +0000
        Re: Comparisons and sorting of a numeric class.... Andrew Robinson <andrew3@r3dsolutions.com> - 2015-01-15 17:45 -0800
          Re: Comparisons and sorting of a numeric class.... Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-16 18:33 +1100
          Re: Comparisons and sorting of a numeric class.... Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2015-01-17 00:07 +1300
          Re: Comparisons and sorting of a numeric class.... Rustom Mody <rustompmody@gmail.com> - 2015-01-16 03:22 -0800
          Re: Comparisons and sorting of a numeric class.... Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-17 23:27 +1100
        Re: Comparisons and sorting of a numeric class.... Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-01-16 02:27 +0000
        Re: Comparisons and sorting of a numeric class.... Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-15 22:01 -0700
        Re: Comparisons and sorting of a numeric class.... Chris Angelico <rosuav@gmail.com> - 2015-01-16 17:58 +1100
      Re: Comparisons and sorting of a numeric class.... Rob Gaddi <rgaddi@technologyhighland.invalid> - 2015-01-15 09:54 -0800
        Re: Comparisons and sorting of a numeric class.... Andrew Robinson <andrew3@r3dsolutions.com> - 2015-01-26 15:47 -0800
        Re: Comparisons and sorting of a numeric class.... Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-26 18:50 -0700
    Re: Comparisons and sorting of a numeric class.... Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-15 10:05 -0700
    Re: Comparisons and sorting of a numeric class.... Andrew Robinson <andrew3@r3dsolutions.com> - 2015-01-23 03:46 -0800
      Re: Comparisons and sorting of a numeric class.... Rustom Mody <rustompmody@gmail.com> - 2015-01-23 07:31 -0800
        Re: Comparisons and sorting of a numeric class.... Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-23 09:50 -0700
          Re: Comparisons and sorting of a numeric class.... Rustom Mody <rustompmody@gmail.com> - 2015-01-23 09:03 -0800
            Re: Comparisons and sorting of a numeric class.... Chris Angelico <rosuav@gmail.com> - 2015-01-24 04:23 +1100
              Re: Comparisons and sorting of a numeric class.... Rustom Mody <rustompmody@gmail.com> - 2015-01-23 09:29 -0800
            Re: Comparisons and sorting of a numeric class.... Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-23 11:04 -0700
              Re: Comparisons and sorting of a numeric class.... Rustom Mody <rustompmody@gmail.com> - 2015-01-23 19:13 -0800
              Re: Comparisons and sorting of a numeric class.... Rustom Mody <rustompmody@gmail.com> - 2015-01-23 19:21 -0800
            Re: Comparisons and sorting of a numeric class.... Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-24 16:01 +1100
              Re: Comparisons and sorting of a numeric class.... Chris Angelico <rosuav@gmail.com> - 2015-01-24 16:43 +1100
          Re: Comparisons and sorting of a numeric class.... Rustom Mody <rustompmody@gmail.com> - 2015-01-23 09:22 -0800
            Re: Comparisons and sorting of a numeric class.... Chris Angelico <rosuav@gmail.com> - 2015-01-24 04:37 +1100
              Re: Comparisons and sorting of a numeric class.... Rustom Mody <rustompmody@gmail.com> - 2015-01-23 09:45 -0800
                Re: Comparisons and sorting of a numeric class.... Chris Angelico <rosuav@gmail.com> - 2015-01-24 05:03 +1100
                Re: Comparisons and sorting of a numeric class.... Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-23 11:13 -0700
      Re: Comparisons and sorting of a numeric class.... Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-24 19:27 +1100
    Re: Comparisons and sorting of a numeric class.... Chris Angelico <rosuav@gmail.com> - 2015-01-23 22:58 +1100
    Re: Comparisons and sorting of a numeric class.... Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-01-23 12:07 +0000
    Re: Comparisons and sorting of a numeric class.... Terry Reedy <tjreedy@udel.edu> - 2015-01-23 11:17 -0500
    Re: Comparisons and sorting of a numeric class.... Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-23 11:00 -0700

csiph-web