Created
August 31, 2021 14:45
-
-
Save dutc/5358862a1905db3948c46d45f35ee75d to your computer and use it in GitHub Desktop.
“Python Expert” Newsletter (Sep 8, 2021): Learning Corner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A: | |
def foo(self): | |
return 'A.foo', | |
class B(A): | |
def foo(self): | |
return 'B.foo', *super().foo() | |
class C(A): | |
def foo(self): | |
return 'C.foo', *super().foo() | |
class D(B, C): | |
def foo(self): | |
return 'D.foo', *super().foo() | |
if __name__ == '__main__': | |
print( | |
f'{A.__mro__ = }', | |
f'{A().foo() = }', | |
f'{B.__mro__ = }', | |
f'{B().foo() = }', | |
f'{C.__mro__ = }', | |
f'{C().foo() = }', | |
f'{D.__mro__ = }', | |
f'{D().foo() = }', | |
sep='\n' | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For the full write-up and discussion, sign up for the “Python Expert” newsletter!
bit.ly/expert-python