daily pastebin goal
34%
SHARE
TWEET

Untitled

a guest Nov 22nd, 2017 52 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
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top