Comparisons and sorting of a numeric class....

Dave Angel davea at davea.name
Wed Jan 7 08:16:24 CET 2015


On 01/06/2015 10:37 PM, Andrew Robinson wrote:
>
> On 01/06/2015 06:31 PM, Chris Angelico wrote:
>>
>
> I already KNOW that 'C++' does have a workaround mechanism, as I've
> mentioned in a different e-mail, so that there's no reason to
> instantiate an instance of the subclass of a singleton if you don't want
> to.  That objection is really spurrious... so I really don't understand
> why Rossum cut off subclassability itself ... wasn't there any other way
> he could have prevented instantiation of subclasses without preventing
> the definition of a subclass itself?
>
> I mean, even in python I can execute some methods of a class without
> actually INSTANTIATING that class.
> eg:
>
> import decimal
> decimal.getcontext()

Interesting that you pick as your example an ordinary function, not in a 
class at all.  In this example, decimal is a module;  you're calling a 
module level function.  Perfectly normal.

But you're right, you can call staticmethods of a class without 
instantiating it, and you can also call classmethods.  But in both 
cases, the caller knows exactly what class he's referring to.  Doesn't 
help your argument any.

If you're not going to instantiate the class, then the fact that such a 
class is, or is not, a subclass of another is invisible, in any context 
I can think of (other than debuggers and such that do inspection by 
reflection).

-- 
DaveA



More information about the Python-list mailing list