Is this Pythonic?

Erik Max Francis max at alcyone.com
Tue Aug 2 02:15:35 EDT 2005


phil hunt wrote:

> That's a clever trick, but it's obvious from the code that the class 
> is intended to be abstract, so if people are stupid enough to shoot 
> themselves in the foot by creating an instance, I don't feel like 
> adding extra code to protect themselves from their stupidity.

Right.  But even if you're not worried about stupidity, it's useful to 
have it fail in an explicit way as early as possible, rather than later 
on.  With that addition, the moment you try to create an instance of an 
abstract class, you get an exception.  Even if it's just a typo, and not 
severe negligence, that helps the problem get fixed sooner, rather than 
later.

-- 
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
   Morality is a weakness of the mind.
   -- Arthur Rimbaud



More information about the Python-list mailing list