Op Tuesday 28 Apr 2015 09:33 CEST schreef Cecil Westerhof: > If I remember correctly you can not hide variables of a class or > make them read-only? > > I want to rewrite my moving average to python. The init is: > def __init__(self, length): > if type(length) != int: > raise ParameterError, 'Parameter has to be an int' > if n < 0: > raise ValueError, 'Parameter should be greater or equal 2' > self.length = length > self.old_values = [] > self.current_total = 0 > > But when someone changes length, old_values, or current_total that > would wreck havoc with my class instance. What is the best way to > handle this?
I have posted it on: https://github.com/CecilWesterhof/PythonLibrary/blob/master/utilDecebal.py -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof -- https://mail.python.org/mailman/listinfo/python-list