What does Python’s builtin __build_class__ do?

Compiling the PEP 3115 metaclass

Guido van Rossum said:

The PEP proposes that the class
statement accepts keyword arguments,
*args, and **kwds syntax as well as positional bases. This is a bit messy
to compile and execute, but we already
have this, of course, in the code for
calling regular functions.

So I think it would be acceptable to
this into a call to a new (hidden)
built-in function, named
__build_class__. Then that this class definition:

  class C(A, B, metaclass=M, other=42, *more_bases, *more_kwds):
    ...

would translate into this:

  C = __build_class__(<func>, 'C', A, B, metaclass=M, other=42,
*more_bases, *more_kwds)

where <func> is a function object for
the class body.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)