What do you call a class not intended to be instantiated

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Sun Sep 28 04:47:11 CEST 2008


On Sat, 27 Sep 2008 17:41:42 -0400, Terry Reedy wrote:

> In 3.0, at least, one does not need a disk file to create a module.
> 
>  >>> import types
>  >>> me = types.ModuleType('me') # type(__builtins__) works, no import
>  >>> me
> <module 'me' (built-in)>
>  >>> me.a = 1
>  >>> me.a
> 1
>  >>> me.a + 1
> 2

Seems to work for Python 2.5 as well.


> That said, a blank class is even easier, and the representation is
> better.

And modules aren't callable. I've often thought they should be.


-- 
Steven



More information about the Python-list mailing list