What do you call a class not intended to be instantiated

Rhamphoryncus rhamph at gmail.com
Mon Sep 22 09:37:52 CEST 2008

On Sep 21, 4:39 pm, Steven D'Aprano <st... at REMOVE-THIS-
cybersource.com.au> wrote:
> I have a class which is not intended to be instantiated. Instead of using
> the class to creating an instance and then operate on it, I use the class
> directly, with classmethods. Essentially, the class is used as a function
> that keeps state from one call to the next.
> The problem is that I don't know what to call such a thing! "Abstract
> class" isn't right, because that implies that you should subclass the
> class and then instantiate the subclasses.
> What do you call such a class?

If defining it as a normal class, it is a namespace.  Just a way to
cluster multiple globals into a single global.  The borg pattern does
the same thing, but with a 12 page treatise on why it shouldn't do
exactly what it's doing.

If using a factory you should probably be using an instance; the fact
that your instance is a class is a relatively minor implementation
detail.  Indeed, the only reason to have a class is to have your
methods bound when looked up.

You might want a metaclass to cripple it, preventing subclassing and
whatnot.  *shrug*.

More information about the Python-list mailing list