【发布时间】:2011-05-04 19:22:54
【问题描述】:
我今天遇到了一段代码,看起来像这样:
class ClassName(object):
def __init__(self):
self._vocabulary = None
def vocabulary(self):
self._vocabulary = self._vocabulary or self.keys()
return self._vocabulary
self._vocabulary = self._vocabulary or self.keys() 行到底在做什么?
【问题讨论】:
-
你的代码 sn-p 的第一部分是无效的 Python 语法。
-
不完全;我已经为你更正了类声明。
标签: python