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: 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> <54AC97D9.4010504@r3dsolutions.com> <54ACAA04.60801@r3dsolutions.com> <54ADC99F.3020405@stoneleaf.us> <54B44A64.7010105@r3dsolutions.com> <54b4aded$0$2738$c3e8da3$76491128@news.astraweb.com> <54B5B486.7080406@r3dsolutions.com> <54B72D32.3090209@r3dsolutions.com> <20150115095452.072d5763@rg.highlandtechnology.com> <54C6D1FD.6070901@r3dsolutions.com> From: Ian Kelly Date: Mon, 26 Jan 2015 18:50:07 -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: 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 On Mon, Jan 26, 2015 at 4:47 PM, Andrew Robinson 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