Correct approach to validate attributes of an instance of class
- by systempuntoout
Having a simple Python class like this:
class Spam(object):
__init__(self, description, value):
self.description = description
self.value = value
Which is the correct approach to check these constraints:
"description cannot be empty"
"value must be greater than zero"
Should i:
1.validate data before creating spam object…