-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproperty-examples.py
More file actions
38 lines (29 loc) · 798 Bytes
/
Copy pathproperty-examples.py
File metadata and controls
38 lines (29 loc) · 798 Bytes
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
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
__author__ = 'Administrator'
class Screen(object):
@property
def width(self):
return self._width
@width.setter
def width(self, value):
if not isinstance(value, int):
raise ValueError('width must be an integer!')
self._width = value
@property
def height(self):
return self._height
@height.setter
def height(self, value):
if not isinstance(value, int):
raise ValueError('height must be an integer!')
self._height = value
@property
def resolution(self):
return self._height * self._width
#test
s = Screen()
s.width = 1024
s.height = 768
print(s.resolution)
assert s.resolution == 786432, '1024 * 768 = %d ?' % s.resolution