Shared publicly  - 
Yesterday I convinced myself that there was no such thing as safe (read: protected variables) in Python. Today's version of myself woke up still on the fence.

So I wrote this:

For a while I was all like, oh snap, you can't access the cache from the objects, totally safe all day baby.

But then:

In [0]: s = SuperSafe()
Out[0]: <_main_.SuperSafe at 0x1097cde90>

In [1]: s.value
Out[1]: 9

In [2]: SuperSafe.value.fget.func_closure[0].cell_contents.cache
Out[2]: {'0x1097cde90__value': 9}

In [3]: SuperSafe.value.fget.func_closure[0].cell_contents.cache['0x1097cde90__value'] = 100
Out[3]: 100

In [4]: s.value
Out[4]: 100
So many sad faces
pastebin | #1 paste tool since 2002. create new paste; tools; api; archive; real-time; faq. pastebin Follow @pastebin. create new paste; trending pastes. sign up; login; my settings; my profile. My Pa...
Add a comment...