python.begin Starts a Python code snippet |
||||||
Usage |
||||||
python.begin [-n] [-q] [(<python_context>[,<arg0>[,<arg1>[...]]])] <python code> python.end |
||||||
Description |
||||||
Indicates the beginning of a snippet of Python code.
The whole code part between python.begin and python.end
is executed in a Python interpreter.
If python.end is omitted then it is implicitly assumed
that the code from python.begin to the end of the command
buffer is Python. Each Python code execution is bound to a python context (that is in fact a particular instance of a Python interpreter). If <python_context> is not specified or it is an empty string then temporary Python interpreter is created and destroyed just after the code snippet has terminated execution. If <python_context> is specified then a Python interpreter keyed to that context is used: if it was already existing then it is reused otherwise it is created. Any <python_context> is persistent: it maintains the function declarations and Python variable states until explicitly destroyed with python.destroy (or the pythoncore module is forcibly unloaded). The <arg0>,<arg1>,... arguments, if present, are passed to the Python code snippet in the aArgs list (accessible as aArgs[0],aArgs[1]...). The return value of the Python code is propagated to the current context (just like setreturn was called on it) unless the -n switch is used. The -q switch prevents from the command from printing any warning. See the python scripting documentation for more information. |
||||||
Switches |
||||||
|
||||||
Examples |
||||||
python.begin kvirc.eval("echo \"Hello World from python!\""); python.end | ||||||