Automation & scripting
CLI tools, scheduled jobs, filesystem tasks, and glue scripts that save time.
Build an RSS feed from markdown blog posts in Python
Scans a folder of markdown files, extracts titles, dates, and excerpts, and generates a valid RSS 2.0 XML feed.
import re
from pathlib import Path
from xml.etree.ElementTree import Element, SubElement, tostring
from datetime import datetime, timezone
from xml.dom import minidom
def build_rss(blog_dir, site_url="https://example.com"):
feed = Element("rss", version="2.0")
channel = SubElement(feed, "channel")
SubElem…
Convert DOCX to Text by Unzipping XML in Python
Extract plain text from a .docx file by unzipping the container and parsing word/document.xml with regex, using only Python's standard library.
import zipfile
import re
from pathlib import Path
def docx_to_text_unzip_xml(docx_path: str) -> str:
"""Extract plain text from a .docx file by unzipping and parsing document.xml."""
docx_path = Path(docx_path)
if not docx_path.exists():
raise FileNotFoundError(f"File not found: {docx_path}")
…
Browse by section
Each section groups closely related Python snippets.
Automation & scripting — Python code examples
What you will find here
This page collects automation & scripting 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.