views:

48

answers:

1

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?

+1  A: 

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.

Alex Martelli
Thanks, Alex. I'm pretty sure your suggestion worked, as that instance of the error disappeared when I incorporated your fix.Unfortunately, now it throws a similar error from within an .egg file, so I may need to abandon the db method entirely--it looks like that syntax is prevalent in the BOSS framework.
Dan