xp() - Code Explanation
- Code & Script Explanation – Explains Python prompts or local
.pyscript files in clear, step-by-step markdown overview sections.
Signature
ranno.xp(prompt: str, data: Optional[str] = None, config: Optional[dict] = None) -> AIResult| Parameter | Type | Required | Description |
|---|---|---|---|
| prompt | str | Yes | The natural language request or code instruction. |
| data | str | No | File path to target target Python script (.py). Reads file contents automatically. |
| config | dict | No | Optional configuration overrides. |
| Returns | Description |
|---|---|
| AIResult | Subclass of string containing the step-by-step markdown explanation. |
xp() - API
from ranno import xp, cf
# Explain prompt directly
explanation = xp("Explain how a quicksort algorithm works in Python")
print(explanation)
# Explain a local Python script file
file_explanation = xp("Explain this code", data="script.py")
print(file_explanation)
# Explain with custom configuration
my_config = cf(api_key="api_key", model="model_name")
xp("Explain decorators", config=my_config)