Using static variables in Python classes and functions

From , 3 Years ago, written in Python, viewed 54 times.
URL https://pastebin.vip/view/9fa04f87
  1.  
  2. class foo:
  3.     def __init__(self, n=0):
  4.         self.n = n
  5.     def __call__(self, i):
  6.         self.n += i
  7.         return self.n
  8.    
  9. a=foo()
  10. print a(1)
  11. print a(2)
  12. print a(3)
  13. print a(4)
  14.  
  15.  
  16. #//python/7365

Reply to "Using static variables in Python classes and functions"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website