Search code examples
pythonmongodbcherrypy

Why '$pull' does not work in cherrypy


I used $pull for removing a field in embedded document in mongodb. i used cherrypy to implemet this. this is my code.

models.login_info.update({},{$pull:{location:{time:date}}})

but while i run this code it gives me lexical error as follows.

Lexical error at line 48, column 39. Encountered: "$" (36), after : ""

in the terminal i get the following error notification

models.login_info.update({},{$pull:{location:{time:date}}}) ^ SyntaxError: invalid syntax


Solution

  • Wrap $pull in quotes:

    '$pull': {...