Package rivescript :: Module python :: Class PyRiveObjects
[hide private]
[frames] | no frames]

Class PyRiveObjects

source code

A RiveScript object handler for Python code.

This class provides built-in support for your RiveScript documents to include
and execute object macros written in Python. For example:

    > object base64 python
        import base64 as b64
        return b64.b64encode(" ".join(args))
    < object

    + encode * in base64
    - OK: <call>base64 <star></call>

Python object macros receive these two parameters:

    rs:   The reference to the parent RiveScript instance
    args: A list of argument words passed to your object macro

Python support is on by default. To turn it off, just unset the Python language
handler on your RiveScript object:

    rs.set_handler("python", None)

Instance Methods [hide private]
 
__init__(self) source code
 
load(self, name, code)
Prepare a Python code object given by the RiveScript interpreter.
source code
 
call(self, rs, name, user, fields)
Invoke a previously loaded object.
source code
Class Variables [hide private]
  _objects = {}