cogapp
Cog: A content generator for executing Python snippets in source files.
Decision gist · record as of 2026-08-14
Yes. Cog is lightweight, actively maintained, has no dependencies, and solves a specific problem well: keeping computed content in sync with its source code. Install it if you need to embed executable Python in static files and regenerate their output on demand. The MIT license and broad Python version support make it low-risk.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.9 or later.
- Low friction: pure Python wheel with no runtime dependencies.
- Active maintenance with recent commits and stable production status across Python 3.9–3.14.
License · maintenance · safety
MIT (permissive) — MIT license permits commercial and private use with minimal restrictions; attribution required.
last release 2025-09-21 (327 days) · last repo commit 2026-08-05 · 408 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 253,549 downloads/mo, #8,516 on PyPI
Alternatives
Verify before relying
pip install cogapp
In a source file, mark a code block with special delimiters, then run cogapp to execute the embedded code and replace the marked section with its output.- Whether the package handles complex nested code generation or only simple linear snippets.
- Performance characteristics on large files or many embedded snippets.
- Integration patterns with common static site generators (Hugo, Jekyll, Sphinx).
- Exact syntax and delimiter format for marking code blocks in different file types.
What it is and what it does
Cog is a content generator that finds Python code blocks marked in source files, executes them, and replaces the marked regions with their output. It's designed for static files—documentation, HTML, configuration, or any text format—where you want computed or templated content without a full build system. The tool reads the source, runs the embedded Python, and writes the result back in place.
It has no external runtime dependencies and runs on Python 3.9 and later. The workflow is straightforward: mark a code block with special comments, run the tool on the file, and the output replaces the marked section. This is useful for keeping generated content (like tables, API docs, or configuration examples) in sync with the code that produces them, without requiring a separate templating language or build step.
Use it for
- Keep API documentation examples in sync by embedding Python code that generates them.
- Generate configuration file snippets or boilerplate from Python logic.
- Maintain data tables or reference lists in markdown by computing them from live data.
- Embed test output or validation results directly into README or guide files.
- Generate HTML or XML fragments from Python without a full template engine.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
Cog is lightweight, actively maintained, has no dependencies, and solves a specific problem well: keeping computed content in sync with its source code. Install it if you need to embed executable Python in static files and regenerate their output on demand. The MIT license and broad Python version support make it low-risk.
Install
cogapp on PyPI
Before you install
Low friction: pure Python wheel with no runtime dependencies. Active maintenance with recent commits and stable production status across Python 3.9–3.14.
Requires Python 3.9 or later.
License in practice
MIT license permits commercial and private use with minimal restrictions; attribution required.
Quickstart
pip install cogapp
In a source file, mark a code block with special delimiters, then run cogapp to execute the embedded code and replace the marked section with its output.
Verify before relying
- Whether the package handles complex nested code generation or only simple linear snippets.
- Performance characteristics on large files or many embedded snippets.
- Integration patterns with common static site generators (Hugo, Jekyll, Sphinx).
- Exact syntax and delimiter format for marking code blocks in different file types.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.9 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 327 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 253,549 / month, #8,516 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableEnvironment :: ConsoleIntended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9Topic :: Software Development :: Code Generators |
Evidence: cogapp-3.6.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “code generation from python snippets”
- cogappCog executes Python code snippets embedded in source files and…
- PyLaTeXPyLaTeX generates LaTeX documents and code snippets from Python,…
- streamlit-embedcodeEmbeds code snippets from external services (GitHub gist, GitLab,…
Give your agent the search over MCP, or paste the wish link into any chat.
More Code Generators packages
Proto Plus wraps protocol buffers to provide Python classes that behave like native Python types while maintaining protocol buffer serialization and schema validation.
Install it if you're working with protocol buffers in Python and want a more Pythonic interface, or if you're using Google Cloud libraries that depend on it.
Cython is a source code translator that compiles Python code to C, enabling optional static typing and direct C/C++ interoperability to generate efficient native extensions.
Install it if you need to optimize Python performance, wrap C/C++ libraries, or build fast native extensions.
Annotates Python abstract syntax trees with the positions of tokens and source code text, enabling tools to map AST nodes back to their originating code for refactoring, analysis, and transformation.
Beartype is a runtime type checker that validates Python type hints at function call time, catching type violations before they cause downstream bugs.
Install it if you want runtime type safety for your annotated code or need to validate type hints on third-party packages.
llvmlite provides a lightweight Python binding to LLVM's IR builder, optimizer, and JIT compiler APIs, enabling you to write JIT compilers and code generators without needing the full LLVM C++ API surface.
astor converts Python abstract syntax trees (ASTs) back to readable source code and provides tools for AST manipulation, inspection, and non-recursive tree traversal.
Install it if you need AST round-tripping or advanced tree inspection.
See also markdown-exec · cog · ct3 · Cheetah3 · streamlit-embedcode · rio-cogeo · coverage · PyLaTeX · html5tagger · sybil