Home>
class Test (object):
def __init __ (self):
self.test = 0
class Test2 (Test):
def __init __ (self):
Test () .__ init __ (self)
def hoge (self, data):
print (data)
If i have defined a class like the above, you can add the hoge method of the parent class: Test to the child class: Test2 to the parent class:
Please teach me how to call with Test.
-
Answer # 1
Related articles
- python - link extraction method in the specified class
- how to add python built-in class method
- ruby - i want to know the reason for implementing it in a class method or module when solving an exercise
- about excel → json generation method from python
- python - ball bounce method?
- python - yolo i want to detect only a specific class
- python - cannot inherit a class with multiple arguments
- python - i'm looking for a method like the countif function in excel for pywin32
- how to get the movement in the child frame with javascript of the parent frame in iframe
- python - wait for user reaction using wait_for method in discordpy
- python 3x - i want to daemonize a python program, but i want to see if this method works
- python - timestamp type data formatting method
- [vuejs] i want to update the child value when the parent value changes
- python 3x - how to use python class
- i want to save parent and child tables at the same time with wordpress db
- java: parent class access modifier access to protected and static methods
- python - 3 class classification by keras
- html - how to call a method in python
- python - background program by sharley method
- i can't get child elements by scraping python
Trends
- python - you may need to restart the kernel to use updated packages error
- dart - flutter: the instance member'stars' can't be accessed in an initializer 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
- javascript - how to check if an element exists in puppeteer
- sh - 'apt-get' is not recognized as an internal or external command, operable program or batch file
- i want to check the type of a shell script variable
- i want to call a child component method from a parent in vuejs
You can use it if you call.
However, this design is bad because the parent class depends on the child class.
If you actually write code like the following, you'll get an error:
There are some workarounds, but it is better to revisit the design itself.
Addendum:
When using the parent class as an abstract class,
In other words, this is not the case if instantiating the Parent itself is incorrect.