What do you call a class not intended to be instantiated

Ben Finney bignose+hates-spam at benfinney.id.au
Mon Sep 22 02:46:19 CEST 2008

Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> writes:

> 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.

Classes aren't designed to keep state; state is kept in instances.

I think you want Alex Martelli's 'Borg' pattern
which is a class where each instance shares the same state.

 \         “Pinky, are you pondering what I'm pondering?” “I think so, |
  `\     Brain, but there's still a bug stuck in here from last time.” |
_o__)                                           —_Pinky and The Brain_ |
Ben Finney

More information about the Python-list mailing list