I'm looking for recommendations for automated validation of instance variables in Python objects. The validation should occur immediately upon instantiation or setting.
For example, imagine a class like:
import recordtype
class TemperatureReading(recordtype.recordtype('TemperatureReading',
['lat','long','alt','temp'])):
pass
I'd like to be able to constrain lat to +/- 90, long to +/- 180, alt >=0, and temp >=0 .
Writing getters and setters seems too un-Pythonic and tedious. Is there a better way?