Origin is built on top of Python, and theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/boblio-max/origin/llms.txt
Use this file to discover all available pages before exploring further.
py { } block makes that relationship explicit and useful. Whenever you need a Python library, a language feature that Origin doesn’t expose directly, or a utility function you’d rather write in standard Python, you can drop into Python at any point in your .or script with no boilerplate and no context switching. Code inside py { } is passed verbatim to Python’s exec() and shares the same variable scope as the rest of your Origin program.
Syntax
{ and closing } is treated as raw Python. The Origin lexer and parser do not interpret anything inside the braces — only the surrounding py keyword and the brace delimiters are consumed by Origin’s grammar. Nested { and } are handled correctly: the parser tracks brace depth so that Python dict literals, set comprehensions, and similar constructs do not accidentally close the block early.
How It Compiles
When the Origin parser encounterspy { ... }, it captures the content between the braces as a raw string and produces a PyNode AST node. The interpreter’s code generator then emits that string verbatim with no transformation whatsoever:
Scope Sharing
Origin variables and Python variables share the same execution globals dictionary. This means you can freely read and write Origin variables from inside apy block, and any names you define in a py block are immediately available to subsequent Origin statements.
result inside the py block is visible to print result below it because both operate on the same globals dict.
Example: Standard Library Access
The idiomatic way to reach any Python standard library module is to import it inside apy block:
py block runs, math and os are bound in the shared globals and can be referenced by subsequent py blocks in the same script.
Example: Define a Python Function, Call It from Origin
You can define a Python function inside apy block and then call it from Origin code:
clamp is defined in the shared globals by the py block and is immediately callable as an expression anywhere in the Origin script that follows.
The exec Keyword
Origin also provides an exec keyword for running a separate Origin script embedded as a string literal. It is entirely distinct from py { }:
exec, it writes the string content to a temporary file (temp_exec.py) and then invokes runner.py on that file via subprocess.run(). The string is interpreted as Origin source code — it goes through the full lex → parse → generate → execute pipeline in a subprocess. It is not a shell command and does not invoke a system shell.
exec when you need to run a fragment of Origin code dynamically from a string. For shell commands or system utilities, use a py { } block with Python’s subprocess module directly:
Python indentation rules apply inside
py blocks. The block content is passed directly to exec(), so Python’s significant-whitespace rules are fully in effect. Indent function bodies, if branches, loops, and class definitions exactly as you would in a standard .py file. The outer py { } braces are Origin syntax and do not themselves create an indentation level.