Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Denis McMahon Newsgroups: comp.lang.python Subject: Re: Classes Date: Sun, 2 Nov 2014 12:27:06 +0000 (UTC) Organization: A noiseless patient Spider Lines: 26 Message-ID: References: <5453c1a6$0$12981$c3e8da3$5496439d@news.astraweb.com> <7pg75alj1qn97hlirk81f7nqd265emgu05@4ax.com> <20141031104319.02e1ca6f@rg.highlandtechnology.com> <2i585a5s6d1aagbh6ot2b88i51o8jhq0db@4ax.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Sun, 2 Nov 2014 12:27:06 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="66ffcfa4470a58bcddbdcd1913f98ab4"; logging-data="23354"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+B+OUYFYHF8jbivKc1M0LRWMYWREKAuS0=" User-Agent: Pan/0.136 (I'm far too busy being delicious; GIT 926a150 git://git.gnome.org/pan2) Cancel-Lock: sha1:yrS8m7P/5KfSY/KFJC8R6t+MW4E= Xref: csiph.com comp.lang.python:80117 On Sun, 02 Nov 2014 21:32:13 +1100, Tim Delaney wrote: > On 2 November 2014 20:50, Denis McMahon > wrote: > >> The question (I thought) was to write a class for Square that inherited >> a class Rectangle but imposed on it the additional constraints of a >> square over a rectangle, namely that length == width. >> >> > I'm late to the party and this has already been partially addressed in > the thread, but it always annoys me. A square is as much a rhombus with > 90 degree angles as it is a rectangle with equal length and width, and > yet I *never* see the former given as an option. > > If course, that's probably because rectangles have a multitude of uses > for user interfaces, whilst other quadrilaterals are somewhat less > useful. And perhaps that also addresses the square - rectangle (or circle - ellipse) issue - square, rectangle and rhombus are all forms of quadrilateral, and perhaps should all inherit a base class Quadrilateral, rather than trying (and partially failing) to inherit each other. -- Denis McMahon, denismfmcmahon@gmail.com