ex() - Direct Execution
- Scope Propagation – Executes generated Python code directly within the caller's global namespace (
sys._getframe(1).f_globals), allowing it to read, write, and modify local variables inline while automatically printing the script to the console. - Shadow Copy Integrity – Protects local files when the
dataparameter is supplied by creating a temporarycopy.<filename>backup, automatically replacing and restoring the original file if the script execution fails.
Signature
ranno.ex(prompt: str, data: Optional[str] = None, config: Optional[dict] = None) -> AIResult| Parameter | Type | Required | Description |
|---|---|---|---|
| prompt | str | Yes | The natural language command. |
| data | str | No | File path to target CSV, Excel, or JSON dataset. Enables Shadow Copy rollback. |
| config | dict | No | Optional configuration overrides. |
| Returns | Description |
|---|---|
| AIResult | Subclass of string containing the executed code. |
ex() - API
from ranno import ex
# Execute prompt instantly
ex("print('Hello from Ranno execution context')")
# Execute tasks with dataset context
ex("Plot salary vs department", data="employees.csv")