在python中,这更好:
class MyAPI:
def __init__(self):
self.dao = MyDAO()
def getsomething(self):
something = self.dao.grabSomething()
newsomething = operateon(something)
return newsomething
def getsomethingelse()
somethingelse = self.dao.grabSomethingElse()
newsomethingelse = operateon(somethingelse)
return newsomethingelse
OR
class MyAPI:
def getsomething(self):
dao = MyDAO()
something = dao.grabSomething()
newsomething = operateon(something)
return newsomething
def getsomethingelse()
dao = MyDAO()
somethingelse = dao.grabSomethingElse()
newsomethingelse = operateon(somethingelse)
return newsomethingelse
我是来自java spring背景的完整python noob,我真的想了解这里的区别。