class Fred: def __init__(self): self.name = 1 @property def name(self): return self._name @name.setter def name(self, value): if isinstance(value, int): raise Exception("No ints allowed.") self._name = value x = Fred()
Standard input is empty
Standard output is empty
Traceback (most recent call last): File "./prog.py", line 14, in <module> File "./prog.py", line 3, in __init__ File "./prog.py", line 11, in name Exception: No ints allowed.
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!