Skip to main content
本文に 6 文字追加
ソース リンク

Just

class JapanesePerson(Person):
    def say_hello(self):
        print("こんにちは")

If you don't write a new __init____init__, it will automatically uses the old one.

Or

class JapanesePerson(Person):
    def __init__(self, name, age):
        Person.__init__(self, name, age)

If you would do something else in __init____init__.

Using super() is usually the best practice.

Just

class JapanesePerson():
    def say_hello(self):
        print("こんにちは")

If you don't write a new __init__, it will automatically uses the old one.

Or

class JapanesePerson(Person):
    def __init__(self, name, age):
        Person.__init__(self, name, age)

If you would do something else in __init__.

Using super() is usually the best practice.

Just

class JapanesePerson(Person):
    def say_hello(self):
        print("こんにちは")

If you don't write a new __init__, it will automatically uses the old one.

Or

class JapanesePerson(Person):
    def __init__(self, name, age):
        Person.__init__(self, name, age)

If you would do something else in __init__.

Using super() is usually the best practice.

ソース リンク

Just

class JapanesePerson():
    def say_hello(self):
        print("こんにちは")

If you don't write a new __init__, it will automatically uses the old one.

Or

class JapanesePerson(Person):
    def __init__(self, name, age):
        Person.__init__(self, name, age)

If you would do something else in __init__.

Using super() is usually the best practice.