|
4.27.4 pyobject related functions
attrib
- list, get and set attributes (class members) of a pyobject (see attrib)
Example:
| pyobject pystr = "Kublai Khan";
==> no pyobject support
// Additional functionality through attrib
attrib(pystr, "__doc__");
==>
proc(attrib(pystr, "count"))("K");
==> ? proc(`string`) failed
==> ? expected proc(`proc`)
==> ? error occurred in or before ./examples/pyobject_related_functions.si\
ng line 5: ` proc(attrib(pystr, "count"))("K");`
==> ? wrong type declaration. type 'help proc;'
pystr."__doc__"; // <- Short notations
==> ? `pyobject` . `string` failed
==> ? error occurred in or before ./examples/pyobject_related_functions.si\
ng line 7: ` pystr."__doc__"; // <- Short notations`
pystr.count("a"); // Even shorter (if attribute's name is valid and unused)
==> ? `count` is not defined
==> ? error occurred in or before ./examples/pyobject_related_functions.si\
ng line 8: `count("a"); // Even shorter (if attribute's name is \
valid and unused)`
python_run("def func(): return 17");
==> ? `python_run` is not defined
==> ? error occurred in or before ./examples/pyobject_related_functions.si\
ng line 10: ` python_run("def func(): return 17");`
attrib(func);
==> no attributes
attrib(func, "func_name");
==>
attrib(func, "func_name", "byAnyOtherName");
==> ? `func` is not defined
==> ? error occurred in or before ./examples/pyobject_related_functions.si\
ng line 13: ` attrib(func, "func_name", "byAnyOtherName");`
attrib(func, "func_name");
==>
|
killattrib
- deletes an attribute from a pyobject (see killattrib)
Example:
| LIB("pyobject.so");
==> no pyobject support
python_run("def new_pyobj(): pass");
==> ? `python_run` is not defined
==> ? error occurred in or before ./examples/pyobject_related_functions_1.\
sing line 2: `python_run("def new_pyobj(): pass");`
attrib(new_pyobj, "new_attr", "something");
==> ? `new_pyobj` is not defined
==> ? error occurred in or before ./examples/pyobject_related_functions_1.\
sing line 3: `attrib(new_pyobj, "new_attr", "something");`
attrib(new_pyobj, "new_attr");
==>
attrib(new_pyobj);
==> no attributes
killattrib(new_pyobj, "new_attr");
==> ? `new_pyobj` is not defined
==> ? error occurred in or before ./examples/pyobject_related_functions_1.\
sing line 7: `killattrib(new_pyobj, "new_attr");`
attrib(new_pyobj);
==> no attributes
|
python_run
- execute string-given
python commands and import new symbols from
python to 's context (see python_run).
python_eval
- evaluate a string-given
python expression and return the result
to (see python_eval).
python_import
- import
python module into 's context
(see python_import)
|