Implement a custom descriptor that validates integer assignments.
Constraints
Example
>>> class Person: ... age = PositiveInt() ... def __init__(self, age): ... self.age = age >>> p = Person(25) >>> p.age 25 >>> p.age = 0 Traceback (most recent call last): ValueError: age must be greater than zero >>> p.age = 3.14 Traceback (most recent call last): TypeError: age must be an integer >>> del p.age >>> p.age Traceback (most recent call last): AttributeError: 'Person' object has no attribute 'age'
Recent Submissions
No submissions yet — hit Run Tests to try!
Hints