OpenQuizz
Une application de gestion des contenus pédagogiques
Code Class Reference
Inheritance diagram for Code:
Collaboration diagram for Code:

Public Member Functions

def __new__ (cls, code, scope=None, **kwargs)
 
def scope (self)
 
def __repr__ (self)
 
def __eq__ (self, other)
 
def __ne__ (self, other)
 

Detailed Description

BSON's JavaScript code type.

Raises :class:`TypeError` if `code` is not an instance of
:class:`basestring` (:class:`str` in python 3) or `scope`
is not ``None`` or an instance of :class:`dict`.

Scope variables can be set by passing a dictionary as the `scope`
argument or by using keyword arguments. If a variable is set as a
keyword argument it will override any setting for that variable in
the `scope` dictionary.

:Parameters:
  - `code`: A string containing JavaScript code to be evaluated or another
    instance of Code. In the latter case, the scope of `code` becomes this
    Code's :attr:`scope`.
  - `scope` (optional): dictionary representing the scope in which
    `code` should be evaluated - a mapping from identifiers (as
    strings) to values. Defaults to ``None``. This is applied after any
    scope associated with a given `code` above.
  - `**kwargs` (optional): scope variables can also be passed as
    keyword arguments. These are applied after `scope` and `code`.

.. versionchanged:: 3.4
  The default value for :attr:`scope` is ``None`` instead of ``{}``.

Member Function Documentation

◆ __eq__()

def __eq__ (   self,
  other 
)

◆ __ne__()

def __ne__ (   self,
  other 
)

◆ __new__()

def __new__ (   cls,
  code,
  scope = None,
**  kwargs 
)

◆ __repr__()

def __repr__ (   self)

◆ scope()

def scope (   self)
Scope dictionary for this instance or ``None``.

The documentation for this class was generated from the following file: