Python Examples - A Curated Collection
Abstract

A curated collection of practical Python code examples covering modern LLM integrations, web APIs, data processing, security tools, web scraping, and file manipulation. Each example is production-ready with proper error handling, security considerations, and clear documentation. Built by a developer who automates everything and believes good examples are better than lengthy tutorials.

16+ Examples
6 Categories
3.12+ Python

Examples

openai_gpt-example.py

Chat completions, streaming, function calling, JSON mode with GPT-4

openaigptllmchatstreamingai

anthropic_claude-example.py

Claude 3.5 integration with vision, streaming, and extended thinking

anthropicclaudellmvisionai

langchain-example.py

LangChain framework: chains, memory, RAG, and prompt templates

langchainllmragagentschainsai

instructor-example.py

Type-safe structured outputs from LLMs using Pydantic

instructorllmpydanticstructuredvalidationai

grpcio-example.py

gRPC client-server implementation with protocol buffers

grpcrpcprotobufapi

requests-example.py

HTTP requests library examples for API interactions

httprequestsapirest

flask-example.py

Flask web framework with file uploads and routing

flaskwebserverapi

scrapy-spider.py

Scrapy spider for crawling and extracting web data

scrapycrawlingspiderweb

bs4-example.py

BeautifulSoup HTML parsing and DOM manipulation

beautifulsouphtmlparsingdom

sentiment_analysis_nltk-example.py

NLTK sentiment analysis on text data

nltknlpsentimentml

opencv_facial_recognition-example.py

OpenCV face detection and recognition

opencvcvface-detectionml

tor-example.py

Tor network integration for anonymous browsing

torprivacyanonymitynetwork

shodan-example.py

Shodan API for internet-connected device search

shodanosintsecurityapi

hashing_example.py

Cryptographic hashing with SHA-256 and other algorithms

cryptohashingshasecurity

pdfquery-example.py

PDF text extraction and querying

pdftextextractionfiles

exif_reader-example.py

EXIF metadata extraction from images

exifimagesmetadataphotos

Quick Start

# Clone the repository
git clone https://github.com/james-see/python-examples.git
cd python-examples

# Install dependencies (using uv)
uv sync --dev

# Run any example
cd python-examples
python requests-example.py

Why This Collection?

  • Copy-Paste Ready - Working code you can use immediately
  • Security Focused - Input validation, secure defaults, CodeQL verified
  • Modern Python 3.12+ - Using latest features and best practices
  • Real-World Examples - Actual use cases, not toy demos
  • No Fluff - Code first, explanations when needed

Popular Examples

  • gRPC - Modern RPC framework with protocol buffers
  • Flask - Web API with secure file uploads
  • Scrapy - Web scraping at scale
  • Tor Integration - Anonymous network access
  • Shodan API - Internet device search and OSINT
  • OpenCV - Computer vision and face detection

Built with Astro · Hosted on GitHub Pages

Citation: Campbell, J. (2025). python-examples: A Curated Collection. GitHub. https://github.com/james-see/python-examples