Subclass sadness (was Re: [Python-Dev] PEP 285: Adding a bool type)
Aahz
aahz at pythoncraft.com
Sun Mar 31 09:41:28 EST 2002
In article <mailman.1017555459.10956.python-list at python.org>,
Richard Jones <rjones at ekit-inc.com> wrote:
>On Sun, 31 Mar 2002 15:46, Andrew Koenig wrote:
>>
>> The other way around -- inheriting rectangle from square -- would
>> seem to make more sense because a rectangle has all the information
>> that a square does, and then some. But that doesn't really work either,
>> because then you can no longer assume that every kind of square is
>> really a square. After all, it might be a rectangle.
>
>Hrm, just following this thought here, possibly for no good reason at
>all (hey, it's Sunday, and daylight savings just ended so I've got a
>whole _hour_ extra to waste today :)... hell, I can't even remember
>what the point of the circle/ellipse comment was ;)
It was pointing out that inheriting truth/bool from int carries the same
sort of messiness inherent in circle/ellipse.
>Surely sqaure and rectangle (and parallelogram) subclass a more
>fundamental four-sided-shape (er, I can't believe it, but I've
>forgotten the name for them ;)? They impose their own constraints on
>the four-sided-shape, given it has side lengths and angles between the
>sides.
Quadrilateral and parallelogram. But that's still the same sort of
problem when one subclasses, only adding more attributes. ;-)
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
Why is this newsgroup different from all other newsgroups?
More information about the Python-list
mailing list