spyce
         
home     documentation     download     Spyce logo


Documentation - Runtime

Prev: 3.11.1 - Basic usage Up: 3.11 - Programmatic Interface Next: 3.11.1 - Customized Request/Response classes

3.11.1. Passing parameters

One may wish to also pass a parameter from the calling code into the name space used inside the Spyce code so that it may be accessed from Python Statements, Chunks, Expressions, etcetera. Something analogous to Python's own execfile built-in function where you can pass a locals and globals dictionary.

Spyce code to be invoked is dealt with similar to a function body, and hence one can send parameters to that "function" upon invocation. The arguments sig, args and kwargs are used to control such parameter passing. With sig, a signature for this external code is specified, with args and kwargs values for the actual arguments are passed. Thus, sig controls what can go into args and kwargs:

  • sig
    is a string containing a function signature in usual python syntax, without surrounding brackets.
    For example: 'x, y, a=None, b={}'.
  • args
    is a list of values, each value corresponding to a positional argument specified in sig, in order.
  • kwargs
    is a dictionary of name to value mappings, its keys should be in the list of keyword argument names specified in sig, its values provide actual values to be passed.


Prev: 3.11.1 - Basic usage Up: 3.11 - Programmatic Interface Next: 3.11.1 - Customized Request/Response classes


Spyce logo
Python Server Pages
version 2.1.3
Spyce Powered SourceForge Logo