Multiple Inheritance
123456789101112131415161718192021class First: first_attribute = "First" def first_method(self): print("The first_method from the First class") class Second: second_attribute = "Second" def second_method(self): print("The second_method from the Second class") class Child(First, Second): pass instance = Child() print(instance.first_attribute) print(instance.second_attribute) instance.first_method() instance.second_method()
1234567891011class First: attribute = "First" class Second: attribute = "Second" class Child(Second, First): # Order starts from the `Second` pass instance = Child() print(instance.attribute)
Все було зрозуміло?
Дякуємо за ваш відгук!
Секція 2. Розділ 3
Запитати АІ
Запитати АІ
Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат
Awesome!
Completion rate improved to 2.78
Multiple Inheritance
Свайпніть щоб показати меню
123456789101112131415161718192021class First: first_attribute = "First" def first_method(self): print("The first_method from the First class") class Second: second_attribute = "Second" def second_method(self): print("The second_method from the Second class") class Child(First, Second): pass instance = Child() print(instance.first_attribute) print(instance.second_attribute) instance.first_method() instance.second_method()
1234567891011class First: attribute = "First" class Second: attribute = "Second" class Child(Second, First): # Order starts from the `Second` pass instance = Child() print(instance.attribute)
Все було зрозуміло?
Дякуємо за ваш відгук!
Секція 2. Розділ 3