type annotation vs working code

dn PythonList at DancesWithMice.info
Wed Oct 4 04:05:29 EDT 2023


On 04/10/2023 19.41, Chris Angelico via Python-list wrote:
> On Wed, 4 Oct 2023 at 15:27, dn via Python-list <python-list at python.org> wrote:
>> - should the class have been called either;
>>
>>       class SomethingSingleton():
>>
>> or a Singleton() class defined, which is then sub-classed, ie
>>
>>       class Something( Singleton ):
>>
>> in order to better communicate the coder's intent to the reader?
> 
> TBH, I don't think it's right to have a Singleton class which is
> subclassed by a bunch of different singletons. They aren't really
> subclasses of the same class. I could imagine Singleton being a
> metaclass, perhaps, but otherwise, they're not really similar to each
> other.

I'm with you on this - should have made Singleton() an ABC.

Yes, would only be a skeleton around which concrete singleton classes 
could be built.

Like you, I v.rarely use them - but which means that the ABC is useful 
because it would save me from having to remember the curly-bits 
all-over-again...

-- 
Regards,
=dn


More information about the Python-list mailing list