class LockedDown(object):
    __locked = False

def __setattr__(self, name, value):
    if self.__locked:
        if name[:2] != '__' and name not in self.__dict__:
            raise ValueError("Can't set attribute %r" % name)
object.__setattr__(self, name, value)

def _dolock(self):
    self.__locked = True


class Example(LockedDown):

    def __init__(self):
        self.mistakes = 0
self._dolock()

def onemore(self):
    self.mistakes += 1
print(self.mistakes)

def reset(self):
    self.mitsakes = 0
x = Example()
for i in range(3):
    x.onemore()
x.reset()
What's the pythonic way of declaring variables?