Python 2.6 数据库错误
我正在尝试获取雅虎! BOSS 包工作正常,但是当我尝试运行示例文件时,出现以下错误:
$ python examples/ex5.py
File "examples/ex5.py", line 28
tb = db.group(by=["yn$title"], key="rank", reducer=lambda d1,d2: d1+d2, as="total", table=tb, norm=text.norm)
^
SyntaxError: invalid syntax
此特定错误仅发生在 Python 2.6 中。当我尝试在 Python 2.5 中运行时,不会发生此错误(但它会引发其他错误,因为我没有在 2.5 中安装许多其他支持包)。
请注意,所有示例文件在此 db.group 函数上均失败,每种情况下克拉都会突出显示“as”。
是否有与 2.6 相关的更改可能导致此错误?
I'm trying to get the Yahoo! BOSS package working, but when I try to run the example file I get the following error:
$ python examples/ex5.py
File "examples/ex5.py", line 28
tb = db.group(by=["yn$title"], key="rank", reducer=lambda d1,d2: d1+d2, as="total", table=tb, norm=text.norm)
^
SyntaxError: invalid syntax
This particular error only occurs in Python 2.6. When I attempt to run in Python 2.5, this error does not occur (but it throws other errors because I was haven't installed a number of other supporting packages in 2.5).
Note that all the example files fail on this db.group function, with the carat highlighting "as" in each case.
Is there a 2.6-related change that could be causing this error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
as
在 2.5 中是一个伪关键字,它在 2.6 中变成了一个成熟的关键字——这绝对是你的问题的原因!至于解决方法,请尝试在调用末尾添加
**{'as': 'total'}
并删除普通的as='total'
--那应该有效。as
was a pseudo-keyword in 2.5, it's become a full-fledged keyword in 2.6 -- that's definitely the cause of your problem!As for the workaround, try adding a
**{'as': 'total'}
at the end of your call and remove the plainas='total'
-- that should work.