When to Use Object-oriented Programming(Chapter 5 of Python 3 Object Oriented Programming)
code 1 class Silly:
2
3 @property
4 def silly(self):
5 "This is a silly property"
6 print("You are getting silly")
7 return self._silly
8
9 @silly.setter
10 def silly(self, value):
11 print("You are making silly {}".format(value))
12 self._silly = value
13
14 @silly.deleter
15 def silly(self):
16 print("Whoah, you killed silly!")
17 del self._silly
2
3 @property
4 def silly(self):
5 "This is a silly property"
6 print("You are getting silly")
7 return self._silly
8
9 @silly.setter
10 def silly(self, value):
11 print("You are making silly {}".format(value))
12 self._silly = value
13
14 @silly.deleter
15 def silly(self):
16 print("Whoah, you killed silly!")
17 del self._silly

浙公网安备 33010602011771号