Created
January 15, 2016 11:07
-
-
Save ian-ross/2f042452af63a491d2c5 to your computer and use it in GitHub Desktop.
Python weirdie
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
[seneca:~] $ ./tst.py | |
Making an A | |
Calling a.m1 | |
In A.m1 | |
In A._m2 | |
In A._m3 | |
Making an B | |
Calling b.m1 | |
In A.m1 | |
In A._m2 | |
In B._m3 |
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
#!/usr/bin/env python | |
class A: | |
def m1(self): | |
print('In A.m1') | |
self._m2() | |
def _m2(self): | |
print('In A._m2') | |
self._m3() | |
def _m3(self): | |
print('In A._m3') | |
class B(A): | |
def _m3(self): | |
print('In B._m3') | |
print('Making an A') | |
a = A() | |
print('Calling a.m1') | |
a.m1() | |
print('Making a B') | |
b = B() | |
print('Calling b.m1') | |
b.m1() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment