Reference library

Modern tooling

uv, ruff, pyproject.toml, packaging, and current Python project workflows.

3 matches
Modern tooling easy

How to Export a Conda Environment YAML File in Python

Generate a mock conda environment YAML export with a reusable Python function and the PyYAML library.

conda yaml environment
Python
import yaml


def conda_env_mock(name="demo_env", channels=None, packages=None):
    channels = channels or ["defaults"]
    packages = packages or [
        "python=3.11",
        "pip",
        "numpy=1.24.3",
        "pandas=2.0.3",
    ]
    env_dict = {
        "name": name,
        "channels": channels,
        …
17 0 Open
Modern tooling easy

How to List Pre-commit Hooks from YAML Config in Python

Parse a .pre-commit-config.yaml file with PyYAML and print every hook ID paired with its source repository.

pre-commit yaml pyyaml
Python
import yaml

pre_commit_config = """
repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.5.0
    hooks:
      - id: trailing-whitespace
      - id: end-of-file-fixer
      - id: check-yaml
  - repo: https://github.com/psf/black
    rev: 23.11.0
    hooks:
      - id: black
"""

def list_hooks(c…
15 0 Open
Modern tooling easy

How to Parse Taskfile YAML in Python

Load a Taskfile.yaml with PyYAML and simulate task execution by returning each task's commands.

yaml taskfile pyyaml
Python
import yaml
from pathlib import Path

def load_taskfile(taskfile_path: str) -> dict:
    """Load and parse a Taskfile.yaml file into a dict."""
    data = Path(taskfile_path).read_text()
    return yaml.safe_load(data)

def run_task(taskfile: dict, task_name: str) -> dict:
    """Simulate running a task by returning i…
14 0 Open

Browse by section

Each section groups closely related Python snippets.

Modern tooling — Python code examples

What you will find here

This page collects modern tooling snippets — short, copy-ready Python you can paste into our free online IDE and run without installing anything. Each sample includes a plain-English explanation and the full source code.

Samples vs tutorials and challenges

Samples are quick reference — one concept per page. For step-by-step teaching, use our Python tutorials. To test yourself, try quizzes or coding challenges. Clean up style with the Python formatter.