How to define what a class is ?

Ian Kelly ian.g.kelly at
Wed Feb 24 03:46:48 EST 2016

On Wed, Feb 24, 2016 at 1:08 AM, ast <nomail at> wrote:
> Hi
> Since a class is an object, I ask myself how to define rigorously what a
> class is.
> classes are instances from type, but not all, since
> a class may be an instance of a metaclass

All metaclasses are subclasses of type, so all classes are instances of type.

> A class is always callable

It doesn't strictly have to be. You could override the __call__ method
in the metaclass to raise a TypeError if you don't want the class to
be callable. I don't know of a use case for this, though.

> Suppose I provide to you an object and that I
> ask to you to tell me if it is a class or not. How
> would you proceed ?

import inspect

More information about the Python-list mailing list