How many args? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

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

27th Dec 2023, 7:08 PM
Annihilate
Annihilate - avatar
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.
28th Dec 2023, 12:40 AM
Bob_Li
Bob_Li - avatar
+ 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
27th Dec 2023, 7:16 PM
Lisa
Lisa - avatar
+ 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.
28th Dec 2023, 5:58 AM
Rain
Rain - avatar
0
New Game , I only found one instance of "__build_class__" on python.org. https://peps.python.org/pep-0520/#changes
27th Dec 2023, 7:36 PM
Rain
Rain - avatar
0
Rain I canā€™t think of a way you would use this function because I donā€™t know what a metaclass is.
28th Dec 2023, 2:37 PM
Annihilate
Annihilate - avatar
0
New Game , Let's find out. These results are python.org pages that mention metaclass. https://duckduckgo.com/?q=site%3Apython.org%20metaclass
28th Dec 2023, 3:37 PM
Rain
Rain - avatar