简体   繁体   English

Python 2.6 DB错误

[英]Python 2.6 DB error

I'm trying to get the Yahoo! 我正在尝试获得Yahoo! BOSS package working, but when I try to run the example file I get the following error: 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

This particular error only occurs in Python 2.6. 此特定错误仅在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). 当我尝试在Python 2.5中运行时,不会发生此错误(但会引发其他错误,因为我没有在2.5中安装许多其他支持程序包)。

Note that all the example files fail on this db.group function, with the carat highlighting "as" in each case. 请注意,所有示例文件都在此db.group函数上失败,并且在每种情况下克拉都突出显示为“ as”。

Is there a 2.6-related change that could be causing this error? 是否有与2.6相关的更改可能导致此错误?

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 2.5中的伪关键字一样,它在2.6中已成为成熟的关键字-绝对是造成问题的原因!

As for the workaround, try adding a **{'as': 'total'} at the end of your call and remove the plain as='total' -- that should work. 至于解决方法,请尝试在通话结束时添加**{'as': 'total'} ,然后删除普通的as='total'应该可以。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM