What do you call a class not intended to be instantiated

Ben Finney bignose+hates-spam at benfinney.id.au
Sun Sep 21 20:46:19 EDT 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
<URL:http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66531>,
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