以下哪個類將演示設置實例屬性的最佳方法?應該根據情況交替使用它們嗎?返回值的方法與直接在Python中設置屬性的方法
class Eggs(object):
def __init__(self):
self.load_spam()
def load_spam(self):
# Lots of code here
self.spam = 5
或
class Eggs(object):
def __init__(self):
self.spam = self.load_spam()
def load_spam(self):
# Lots of code here
return 5