提交 ac45ec9a authored 作者: Ian Goodfellow's avatar Ian Goodfellow

change to python2.4 compatible syntax

上级 290103dd
...@@ -54,7 +54,10 @@ class OrderedSet(collections.MutableSet): ...@@ -54,7 +54,10 @@ class OrderedSet(collections.MutableSet):
def pop(self, last=True): def pop(self, last=True):
if not self: if not self:
raise KeyError('set is empty') raise KeyError('set is empty')
key = next(reversed(self)) if last else next(iter(self)) if last:
key = next(reversed(self))
else:
key = next(iter(self))
self.discard(key) self.discard(key)
return key return key
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论