Skip to content

Instantly share code, notes, and snippets.

@ian-ross
Created January 15, 2016 11:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ian-ross/2f042452af63a491d2c5 to your computer and use it in GitHub Desktop.
Save ian-ross/2f042452af63a491d2c5 to your computer and use it in GitHub Desktop.
Python weirdie
[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
#!/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