calling child class method from parent class file in python

后端 未结 5 1413
名媛妹妹
名媛妹妹 2021-02-04 01:01

parent.py:

class A(object):
    def methodA(self):
        print(\"in methodA\")

child.py:

from paren         


        
5条回答
  •  不思量自难忘°
    2021-02-04 02:01

    If the both class in same .py file then you can directly call child class method from parents class. It gave me warning but it run well.

    class A(object):

    def methodA(self):
    
        print("in methodA")
    
        Self.methodb()
    

    class B(A):

    def methodb(self):
    
        print("am in methodb")
    

提交回复
热议问题