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

Class PyRiveObjects

source code

object --+
         |
        PyRiveObjects

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)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
call(self, rs, name, user, fields)
Invoke a previously loaded object.
source code
 
load(self, name, code)
Prepare a Python code object given by the RiveScript interpreter.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  _objects = {}
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)