It's the Python feature we've all been waiting for — write-only attributes. This simple decorator makes it so all your attributes are write-only:
@kablooey
class Foo:
def __init__(self, x):
self.x = x
Set these attributes to your heart's content:
foo = Foo(1)
foo.x = 2
foo.x = 3
Knowing that they are safely write-only — keeping them locked aray from prying eyes:
print(foo.x)
The above code would cause the following exception:
Traceback (most recent call last):
File "...", line ..., in <module>
print(foo.x)
^^^^^
File "...", line ..., in __get__
raise Exception("Bang!")
Exception: Bang!