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
What's the pythonic way of declaring variables?