Guest User

Untitled

a guest
Nov 22nd, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. class Test(object):
  2. def test(self, a, b=None):
  3. if isinstance(self, Test):
  4. return a + b
  5. else:
  6. return self + a
  7.  
  8. >>> Test.test(1,2)
  9. 3
  10. >>> Test().test(1,2)
  11. 3
  12.  
  13. TypeError: unbound method test() must be called with Test instance as first argument (got int instance instead)
Add Comment
Please, Sign In to add comment