CodeBlock

Represents a single code block to be typed.

Usage

Source

CodeBlock(
    name,
    code,
    description=None,
    execute=True,
    pause_after=1.0,
    type="code",
    language=None
)

A code block corresponds to a section marked with ## headers in your script file. Each block can have its own execution and timing settings.

Parameters

name: str

Display name of the block (from the ## header)

code: str

The actual code content to type

description: Optional[str] = None

Optional description (not currently used)

execute: bool = True

Whether to execute this block after typing (default: True)

pause_after: float = 1.0

Seconds to pause after typing this block (default: 1.0)

type: Literal["code", "markdown"] = "code"

Block type (default: ‘code’)

language: Optional[str] = None
Language for this specific block (if different from main config)

Examples

>>> block = CodeBlock(
...     name="Import libraries",
...     code="import pandas as pd",
...     execute=True,
...     pause_after=1.5
... )