Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Test:
- def __init__(self, my_val):
- self._myval = my_val
- @property
- def my_val(self):
- return "Value: {0}".format(self._myval)
- @my_val.setter
- def my_val(self, value):
- raise RuntimeError("My val property is read only")
- inst = Test("abc")
- print(inst.my_val)
- inst.my_val = "xyz"
Advertisement
Add Comment
Please, Sign In to add comment