简体   繁体   中英

Python 2.6 DB error

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?

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 plain as='total' -- that should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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