Guest User

Untitled

a guest
Nov 22nd, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. import random
  2.  
  3. def genvalue():
  4. return random.randint(1, 100)
  5.  
  6. class A(object):
  7. def __init__(self, x = genvalue()):
  8. self.x = x
  9.  
  10. class B(A):
  11. def __init__(self):
  12. super(B, self).__init__()
  13.  
  14. t1 = A(10)
  15. t2 = B()
  16. t3 = B()
  17.  
  18. print t1.x
  19. print t2.x
  20. print t3.x
  21.  
  22. class A(object):
  23. def __init__(self, x=None):
  24. if x is None:
  25. self.x = genvalue()
Add Comment
Please, Sign In to add comment