<分区> 分区>
使用 someclass.func 代替 someclass.func() 一直是我的梦想。我阅读了有关 @decorators 的内容。现在我问:
哪种方式更好?
方式一
class Main(object):
def __init__(self):
self.func()
def func(self):
print 'hi'
或者...
方式二
class Main(object):
def __init__(self):
self.func
@property
def func(self):
print 'hi'
编辑
代码如下: http://randomgalaxy.com/stackoverflow/python-property-vs-func/term.py
