code – Tools for representing JavaScript code

    • class Code(code, scope=None, **kwargs)

    BSON’s JavaScript code type.

    Scope variables can be set by passing a dictionary as the scope_argument or by using keyword arguments. If a variable is set as akeyword argument it will override any setting for that variable inthe _scope dictionary.

    • code: A string containing JavaScript code to be evaluated or anotherinstance of Code. In the latter case, the scope of code becomes thisCode’s .
    • **kwargs (optional): scope variables can also be passed askeyword arguments. These are applied after scope and code.

    Changed in version 3.4: The default value for is None instead of {}.

    • Scope dictionary for this instance or None.