Guest User

Is there any advantage in using a Python class

a guest
Feb 26th, 2012
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. class Something(object):
  2.  
  3. @staticmethod
  4. def foo(x):
  5. return x + 5
  6.  
  7. @staticmethod
  8. def bar(x, y):
  9. return y + 5 * x
  10.  
  11. # something.py
  12.  
  13. def foo(x):
  14. return x + 5
  15.  
  16. def bar(x, y):
  17. return y + 5 * x
  18.  
  19. import something
  20. print something.foo(10)
  21. print something.bar(12, 14)
  22.  
  23. class Something(object):
  24. def foo(self, x):
  25. return x + 5
  26.  
  27. def bar(self, x, y):
  28. return y + 5 * self.foo(x)
  29.  
  30. something = Something()
Add Comment
Please, Sign In to add comment