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


Groups > comp.lang.python > #80062

Re: Classes

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.012
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'python.': 0.02; 'alias': 0.09; 'cc:addr:python-list': 0.11; '"is': 0.16; '*any*': 0.16; '8:40': 0.16; '@property': 0.16; 'any.': 0.16; 'choice,': 0.16; 'extraneous': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'inheritance': 0.16; 'non-trivial': 0.16; 'repr()': 0.16; 'subclass': 0.16; 'subject:Classes': 0.16; 'tweak': 0.16; 'demonstrate': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'example': 0.22; 'otherwise,': 0.22; 'cc:addr:python.org': 0.22; 'certainly': 0.24; 'example.': 0.24; 'instance,': 0.24; 'cc:2**0': 0.24; '(for': 0.26; 'certain': 0.27; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'am,': 0.29; 'member.': 0.30; 'message- id:@mail.gmail.com': 0.30; 'agreed.': 0.31; 'probably': 0.32; 'quite': 0.32; "can't": 0.35; 'except': 0.35; 'tool': 0.35; 'test': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'useful': 0.36; 'implement': 0.38; 'nov': 0.38; 'truly': 0.60; 'most': 0.60; 'new': 0.61; 'times': 0.62; 'making': 0.63; 'kind': 0.63; 'such': 0.63; 'more': 0.64; 'square': 0.74; 'article': 0.77; 'belief': 0.84; 'exercise,': 0.84; 'get/set': 0.84; 'to:none': 0.92; 'choice.': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=cOKNBEU9ax2EVnScw/DpoIx1QJ/sCeu9F2YPCd/8nfM=; b=QYmfnsU6Bjfdhdm6iHVNed/SXlzsi0nhWajK1RlE7ftzZcJ0oQ/ON3ViD1sEcMuO8q AYCYejiyNoQoY2Bi/B1Ma9MvTAAJqSkDhMhiBPpn5CygfU4IujMK75NxxKcqMWbnEynC vQJFhSWdyrCRp2WG5pah/N7qB1X7YuIgkg5Gr3VVibNBgSfhe7t0iZ2SjbI0RXfhrGoe PQb7ClOIomQsa9yLLzcA3gDTnBYGqVHeJTtoj8+lyGy0B/N2kVf/HHtYwOXK4F+QIq9g 12m9OnyOlo7Gx89GSVOcpGWCwysEigaMfnaSb9jH+lNpb8f1ZGw0BKbdW7vArrlEzcvT OLPA==
MIME-Version 1.0
X-Received by 10.50.164.233 with SMTP id yt9mr60475igb.2.1414792578881; Fri, 31 Oct 2014 14:56:18 -0700 (PDT)
In-Reply-To <20141031144045.05965228@rg.highlandtechnology.com>
References <51755at03r0bidjqh3qf0hhpvjr8756ill@4ax.com> <545350c3$0$23449$426a74cc@news.free.fr> <bj575ahusmihp1fpm58gmcr2eg0g8k21o6@4ax.com> <5453c1a6$0$12981$c3e8da3$5496439d@news.astraweb.com> <7pg75alj1qn97hlirk81f7nqd265emgu05@4ax.com> <20141031104319.02e1ca6f@rg.highlandtechnology.com> <mailman.15370.1414788668.18130.python-list@python.org> <b90013c1-e27f-430a-8791-1f6da6e024e6@googlegroups.com> <20141031144045.05965228@rg.highlandtechnology.com>
Date Sat, 1 Nov 2014 08:56:18 +1100
Subject Re: Classes
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <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.15373.1414792587.18130.python-list@python.org> (permalink)
Lines 29
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1414792587 news.xs4all.nl 2907 [2001:888:2000:d::a6]:43148
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:80062

Show key headers only | View raw


On Sat, Nov 1, 2014 at 8:40 AM, Rob Gaddi
<rgaddi@technologyhighland.invalid> wrote:
> For this specific exercise, a Square is a subclass of Rectangle because
> the point of Rectangle is to demonstrate that extraneous get/set
> functions are completely unnecessary in Python.  The point of
> Square is to demonstrate that get/set functions can be useful in
> certain circumstances where you need to implement non-trivial behaviors,
> such as making the "width" property into an alias for the "length" true
> data member.

As the Wikipedia article explains, this has its own consequences. A
reasonable test suite for Rectangle would quite probably fail if given
a Square. Hence my belief that this makes for a less-than-ideal
example. But I can't think of *any* good example of @property for a
tutorial. ANY.

> As a learning tool for thinking about inheritance hierarchies it's kind
> of rubbish.  But then again, most inheritance hierarchies are ambigious
> at best, which is why "has a" is often a better choice than "is a".

Agreed. There certainly are times when "is a" is the right choice, but
there are a lot more times when "has a" is the better choice. Usually,
when I subclass, it's because I want to tweak the behaviour of an
existing type (for instance, subclass int and change its repr() to
return hex(self)), so it really truly is a <superclass>, in every way
except that one tiny change. Otherwise, new type with a member. Much
simpler. Much safer.

ChrisA

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


Thread

Classes   Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-30 16:16 -0400
  Re: Classes sohcahtoa82@gmail.com - 2014-10-30 13:33 -0700
    Re: Classes Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-30 17:00 -0400
  Re: Classes Rob Gaddi <rgaddi@technologyhighland.invalid> - 2014-10-30 13:34 -0700
    Re: Classes Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-30 17:00 -0400
  Re: Classes Larry Hudson <orgnut@yahoo.com> - 2014-10-30 14:28 -0700
    Re: Classes Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-30 17:34 -0400
      Re: Classes sohcahtoa82@gmail.com - 2014-10-30 18:21 -0700
      Re: Classes alister <alister.nospam.ware@ntlworld.com> - 2014-10-31 09:59 +0000
        Re: Classes Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-31 10:07 -0400
  Re: Classes   "ast" <nomail@invalid.com> - 2014-10-31 10:05 +0100
    Re: Classes   "ast" <nomail@invalid.com> - 2014-10-31 10:18 +0100
      Re: Classes Chris Angelico <rosuav@gmail.com> - 2014-10-31 20:21 +1100
    Re: Classes   Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-31 10:05 -0400
      Re: Classes Ian Kelly <ian.g.kelly@gmail.com> - 2014-10-31 08:47 -0600
        Re: Classes Grant Edwards <invalid@invalid.invalid> - 2014-10-31 15:49 +0000
          Re: Classes Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-31 12:31 -0400
            Re: Classes Chris Angelico <rosuav@gmail.com> - 2014-11-01 03:37 +1100
              Re: Classes Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-31 12:47 -0400
                Re: Classes Chris Angelico <rosuav@gmail.com> - 2014-11-01 04:02 +1100
                Re: Classes Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-31 13:31 -0400
                Re: Classes Zachary Ware <zachary.ware+pylist@gmail.com> - 2014-10-31 12:39 -0500
                Re: Classes Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-31 13:57 -0400
                Re: Classes Rob Gaddi <rgaddi@technologyhighland.invalid> - 2014-10-31 10:40 -0700
                Re: Classes Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-11-01 11:17 +1300
                Re: Classes Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-11-01 12:06 +1100
                Re: Classes Ian Kelly <ian.g.kelly@gmail.com> - 2014-11-01 00:12 -0600
                Re: Classes Chris Angelico <rosuav@gmail.com> - 2014-11-01 17:32 +1100
                Re: Classes Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-11-03 00:32 +1300
            Re: Classes Dave Angel <davea@davea.name> - 2014-10-31 13:20 -0400
            Re: Classes Marko Rauhamaa <marko@pacujo.net> - 2014-10-31 19:35 +0200
            Re: Classes Grant Edwards <invalid@invalid.invalid> - 2014-10-31 17:40 +0000
            Re: Classes Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-10-31 18:26 -0400
              Re: Classes Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-11-01 12:09 +1100
      Re: Classes   Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-11-01 04:06 +1100
        Re: Classes   Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-31 13:18 -0400
          Re: Classes Rob Gaddi <rgaddi@technologyhighland.invalid> - 2014-10-31 10:43 -0700
            Re: Classes Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-31 14:18 -0400
              Re: Classes Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-31 14:42 -0400
              Re: Classes Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-10-31 18:57 -0400
                Re: Classes Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-31 19:22 -0400
                Re: Classes Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-31 19:32 -0400
                Re: Classes Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-11-01 12:00 -0400
                Re: Classes Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-11-01 12:42 -0400
                Re: Classes Denis McMahon <denismfmcmahon@gmail.com> - 2014-11-02 09:50 +0000
                Re: Classes Tim Delaney <timothy.c.delaney@gmail.com> - 2014-11-02 21:32 +1100
                Re: Classes Denis McMahon <denismfmcmahon@gmail.com> - 2014-11-02 12:27 +0000
                Re: Classes Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-11-02 11:31 -0500
                Re: Classes Denis McMahon <denismfmcmahon@gmail.com> - 2014-11-03 03:12 +0000
                Re: Classes Dan Sommers <dan@tombstonezero.net> - 2014-11-03 06:29 +0000
                Re: Classes Denis McMahon <denismfmcmahon@gmail.com> - 2014-11-04 01:10 +0000
                Re: Classes Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-11-04 18:30 +1300
                Re: Classes Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-11-03 08:50 -0500
                Re: Classes Chris Angelico <rosuav@gmail.com> - 2014-11-04 02:34 +1100
                Re: Classes Ian Kelly <ian.g.kelly@gmail.com> - 2014-11-03 07:47 -0700
                Re: Classes Larry Hudson <orgnut@yahoo.com> - 2014-11-02 14:03 -0800
            Re: Classes Chris Angelico <rosuav@gmail.com> - 2014-11-01 07:51 +1100
              Re: Classes sohcahtoa82@gmail.com - 2014-10-31 14:24 -0700
                Re: Classes Rob Gaddi <rgaddi@technologyhighland.invalid> - 2014-10-31 14:40 -0700
                Re: Classes Chris Angelico <rosuav@gmail.com> - 2014-11-01 08:56 +1100
                Re: Classes Chris Angelico <rosuav@gmail.com> - 2014-11-01 08:36 +1100
          Re: Classes Grant Edwards <invalid@invalid.invalid> - 2014-10-31 17:43 +0000
    Re: Classes Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-10-31 14:11 +0000
    Re: Classes   Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-31 12:49 -0400
      Re: Classes   "ast" <nomail@invalid.com> - 2014-10-31 19:31 +0100
        Re: Classes   Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-31 14:36 -0400
        Re: Classes Joel Goldstick <joel.goldstick@gmail.com> - 2014-10-31 14:41 -0400
          Re: Classes Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-31 14:56 -0400

csiph-web