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


Groups > comp.lang.python > #83659

Re: Comparisons and sorting of a numeric class....

References (6 earlier) <54ACAA04.60801@r3dsolutions.com> <54ADC99F.3020405@stoneleaf.us> <54B44A64.7010105@r3dsolutions.com> <mailman.17645.1421102146.18130.python-list@python.org> <54b4a5ac$0$2738$c3e8da3$76491128@news.astraweb.com>
Date 2015-01-13 16:30 +1100
Subject Re: Comparisons and sorting of a numeric class....
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.17654.1421127061.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Tue, Jan 13, 2015 at 3:57 PM, Steven D'Aprano <steve@pearwood.info> wrote:
> On Tue, 13 Jan 2015 09:35:43 +1100, Chris Angelico wrote:
>
>> Subclassing bool breaks this invariant, unless you never instantiate the
>> subclass, in which case it's completely useless.
>
> Not necessarily. A class that you never instantiate, but use as an object
> itself, is another way of implementing the singleton design pattern.
> Obviously all the methods have to be class methods, but it is doable.
>
> But wacky exceptions like subclasses that aren't instantiated aside,
> normally if you subclass something you intend to instantiate it.

True, I should have said "probably useless" instead of "completely
useless". :) There's always *something* you could do with it.

ChrisA

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


Thread

Re: Comparisons and sorting of a numeric class.... Chris Angelico <rosuav@gmail.com> - 2015-01-13 09:35 +1100
  Re: Comparisons and sorting of a numeric class.... Steven D'Aprano <steve@pearwood.info> - 2015-01-13 04:57 +0000
    Re: Comparisons and sorting of a numeric class.... Chris Angelico <rosuav@gmail.com> - 2015-01-13 16:30 +1100

csiph-web