Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >>> a = 1
- >>> d = {'a':a}
- >>> d['a']
- 1
- >>> a = 2
- >>> d['a']
- 1
- >>> a = 1
- >>> d = {'a':magical pointer to a}
- >>> d['a']
- 1
- >>> a = 2
- >>> d['a']
- 2
- >>> a = mutable_structure(1)
- >>> d = {'a':a}
- >>> d['a']
- 1
- >>> a.setValue(2)
- >>> d['a']
- 2
- class mutable_structure:
- def __init__(self, val):
- self.val = val
- def __repr__(self):
- return self.val
- a = [1]
- d = {'a': a}
- a[0] = 2
- print d['a'][0]
- class Mutable(object):
- pass
- a = Mutable()
- a.value = 1
- d = {'a':a}
- a.value = 3
- class DRefsA(object):
- a = 4
- @property
- def d(self):
- return self.a
- @d.setter
- def d(self, value):
- self.a = value
- a = 1
- d = {'a': lambda : a}
- print(d['a']()) #output 1
- a = 2
- print(d['a']()) #output 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement