Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis0
How many args?
This __build_class__ function needs some amount of arguments, but it doesnāt tell me how much it needs. It just says that there arenāt enough arguments. How many arguments does this thing need? https://sololearn.com/compiler-playground/c7Ngiqy8N3Od/?ref=app
6 Respostas
+ 3
It's an internal function that you would not normally modify. Just let it do it's own thing...
you could do
print(help(__build_class__))
to see what parameters it expects.
+ 2
"Whenever you define a class, the functionĀ __build_class__Ā is called behind the scenes.Ā __build_class__Ā is passed the class code (which is actually, suprisingly, a function) and the class name as arguments."
https://sethdandridge.com/blog/defining-a-custom-class-constructor-in-JUMP_LINK__&&__python__&&__JUMP_LINK
+ 2
Bob_Li ,
Good idea. It's sparse but more than I found on python.org. I think the docstring has typos: an extra s and an unwanted line feed. I'm guessing *bases is a tuple of 0 or more parent classes. / means parameters to the left are positional.
help(__build_class__) # (print not needed)
Output:
Help on built-in function __build_class__ in module builtins:
__build_class
s__(...)
__build_class__(func, name, /, *bases, [metaclass], **kwds) -> class
Internal helper function used by the class statement.
0
New Game ,
I only found one instance of "__build_class__" on python.org.
https://peps.python.org/pep-0520/#changes
0
Rain
I canāt think of a way you would use this function because I donāt know what a metaclass is.
0
New Game ,
Let's find out.
These results are python.org pages that mention metaclass.
https://duckduckgo.com/?q=site%3Apython.org%20metaclass