Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- def genvalue():
- return random.randint(1, 100)
- class A(object):
- def __init__(self, x = genvalue()):
- self.x = x
- class B(A):
- def __init__(self):
- super(B, self).__init__()
- t1 = A(10)
- t2 = B()
- t3 = B()
- print t1.x
- print t2.x
- print t3.x
- class A(object):
- def __init__(self, x=None):
- if x is None:
- self.x = genvalue()
Add Comment
Please, Sign In to add comment