我碰到一段代码走到今天,看起来像这样:这是什么做的(Python)的
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()
干什么?
代码片段的第一部分是无效的Python语法。 – 2011-05-04 19:25:26
谢谢!现在不固定 – dave 2011-05-04 19:27:19
不完全;我已经为你纠正了类声明。 – 2011-05-04 19:32:06