You can write your own, property-like class, but without the __set__
-method. This way, setting the attribute creates an instance-attribute instead of calling a setter-method
import random
class property_getter(object):
def __init__(self, getter):
self.getter = getter
def __get__(self, obj, cls):
return self.getter(obj)
class Random(object):
@property_getter
def random_number(self):
return random.randint(0,10)
x = Random()
print x.random_number
print x.random_number
x.random_number = 5
print x.random_number