Thursday, 15 April 2010

What does Python's builtin __build_class__ do? -


In Python 3.1, there is a new built-in function that I do not know in the builtins module:

__ build_class__ (...) __build_class __ (funk, name, * chairs, metaclass = none, ** kwds) - & gt; Classes used by the statement of the square Interior Assistant Function.

What does this function do? If it is internal then why should it be in the buildings? What is the difference between the type (name, base, dict) function?

PAP proposes that class statement accepts keyword logic, * arguments ,

and **. There is something wrong to compile and execute it, but of course, it is already in the code to make regular calls.

So I think that this is a new hidden in a call) created code, name __ build_class __ . Then the definition of the class:

  class C (A, B, MetaClass = M, Other = 42, * more_base, * more_kwds): ...  
< P> will be translated into:

  c = __build_class __ (& lt; func & gt ;, 'c', a, b, metaclass = m, other = 42, * more_base, * More_kwds)  

Where & lt; Func & gt; is a function object for class body.


No comments:

Post a Comment