Ray's playground

 

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

 

posted on 2010-09-02 20:52  Ray Z  阅读(138)  评论(0编辑  收藏  举报

导航