someclass.func
の代わりに使うのがずっと夢でしsomeclass.func()
た。について読みました@decorators
。そして今、私は尋ねます:
どちらの方法が良いですか?
方法 1
class Main(object):
def __init__(self):
self.func()
def func(self):
print 'hi'
また...
方法 2
class Main(object):
def __init__(self):
self.func
@property
def func(self):
print 'hi'
編集
コードは次のとおりです。 http://randomgalaxy.com/stackoverflow/python-property-vs-func/term.py