[Tutor] a class that may not be instantiated

Alan Gauld alan.gauld at btinternet.com
Tue Nov 24 12:37:43 EST 2015


On 24/11/15 15:36, Albert-Jan Roskam wrote:
> I have two classes with a number of methods that are the same, 
> so I want to define a super class that holds these methods.

So far so good.

> But the super class (below called _Generic) should not be instantiated, 

But here it starts to feel a tad non Pythonic to me. It's not C++.
You can certainly do it (as you show below). But should you?
Is a docstring comment not sufficient? Why would anyone want to
instantiate Generic? And if they do think of a valid reason,
why stop them?


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list