Classes

Denis McMahon denismfmcmahon at gmail.com
Sun Nov 2 07:27:06 EST 2014


On Sun, 02 Nov 2014 21:32:13 +1100, Tim Delaney wrote:

> On 2 November 2014 20:50, Denis McMahon <denismfmcmahon at gmail.com>
> 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 at gmail.com



More information about the Python-list mailing list