I have a class that can be simplified to something like:
class Foo(object):
@property
def x(self):
return 'Boo'
foo = Foo()
foo.x --> 'Boo'
I'm doing some testing/simulation where I want to change the x
accessor property to return a different constant value, just for the foo
instance. Obviously, I can't just use foo.x = '13 Candles'
because it's a property! I tried:
foo.__dict__['x'] = '13 Candles'
But foo.x
still returns 'Boo'
after that?!
I also tried
setattr(foo, 'x', '13 Candles')
Hoping that "bypassed" the accessor machinery. But no such luck. Just an error that it's a read only property.