Currently, I'm studying Python from the basics with the aim of getting a Python certification, and most recently I'm trying to figure out about class inheritance.
The code that describes the original class and the inherited class is as follows.
#Class inheritance "" " Create a new class with the originally created class as the parent class. In addition to inheriting the contents of the parent class with a certain grammar, the child class defines a new class. "" " class FavChara: def __init __ (self, title, name): self.title = title self.name = name class NeoFavChara: def __init __ (self, title, name, prime): super () .__ init __ (title, name) self.prime = prime classes =  classes.append (NeoFavChara ('Dragon Ball','Son Gohan','Son Goku')) classes.append (NeoFavChara ('One Piece','Usopp','Luffy')) classes.append (NeoFavChara ('One Punch Man','Saitama','Saitama')) classes.append (NeoFavChara ('The Promised Neverland',' Emma',' Emma')) classes.append (NeoFavChara ('Kimetsu no Yaiba','Kamado Nezuko','Kamado Kanjiro')) for eachCls in classes: print ("" + eachCls.title + ""'s favorite character: "+ eachCls.name +" (the main character is "+ eachCls.prime +") ")
However, when I ran this with "IDLE (Python 3.8 64-bit)",
Traceback (most recent call last): File "C: \ Users \ user \ Desktop \ PythonTrials \ izm06.py", line 78, in<module> classes.append (NeoFavChara ('Dragon Ball','Son Gohan','Son Goku')) File "C: \ Users \ user \ Desktop \ PythonTrials \ izm06.py", line 74, in __init__ super () .__ init __ (title, name) TypeError: object.__init__ () takes exactly one argument (the instance to initialize)
I get the error, and I can't get to the point where I can output all the contents of the inherited class in the character string.
https://www.tutorialfor.com/go.php?id=157952 First in class from the answers to the questioninitI came up with the possibility that the number of arguments set with is not the same as the number of arguments used at the time of calling, but I still do not know what kind of description should be used to set the arguments. ..
I know that it happened because of a trivial problem, but if anyone knows it, please answer again this time.
Answer # 1
--class NeoFavChara: + class NeoFavChara (FavChara):
- python - regular expression: sub () cannot replace the matched part
- python - about multiple processing and loop processing in discordpy
- python - tfkerasapplication model cannot be downloaded
- python - firebase_admin cannot be imported
- python - all commands cannot be used with discord bot
- i cannot transition from the sbi securities home screen to the futures trading screen by scraping python + selenium
- python - how to load multiple time formats with pandas
- python - discord bot command cannot be started
- python - yolo i want to detect only a specific class
- how to add python built-in class method
- python 3x - multiple outputs from a list of tuples
- text cannot be pasted with multiple lines selected in vscode vim visual mode
- python - variables cannot be defined
- python - idle cannot resolve the "rootgeometry" error
- [python] cannot insert or delete to text box
- python - ephem module cannot be imported in vscode
- python - the csv file cannot be displayed
- python - read multiple audio files (wav files)
- cannot read python dat file
- python - you may need to restart the kernel to use updated packages error
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- i want to call a child component method from a parent in vuejs
- python 3x - typeerror: 'method' object is not subscriptable
- dart - flutter: the instance member'stars' can't be accessed in an initializer error
- xcode - pod install [!] no `podfile 'found in the project directory