class Point object def __init__ self self _x self _y property def self

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
class Point(object):
def __init__(self, x=0, y=0):
self._x = 0
self._y = 0
@property
def x(self):
return self._x
@x.setter
def x(self, value):
if not isinstance(value, int):
except TypeError("Need int value")
self._x = value
@property
def y(self):
return self._x
@x.setter
def y(self, value):
if not isinstance(value, int):
except TypeError("Need int value")
self._y = value
#####################
p = Point(10, 20)
p.x = 25
p.x = "foo"