daily pastebin goal
42%
SHARE
TWEET

Untitled

a guest Nov 22nd, 2017 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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)
RAW Paste Data
Top