📦

Python Packages Overview

Jul 29, 2025

Overview

This lecture introduces 15 useful Python packages for a variety of tasks, including database management, web scraping, mathematics, project setup, serialization, game development, data visualization, templating, file monitoring, functional programming, data conversion, object management, UI creation, and more.

Database Management: SQLAlchemy

  • SQLAlchemy is an Object Relational Mapper (ORM) for working with databases in Python.
  • It lets you define tables as Python classes, simplifying CRUD operations.
  • ORMs provide easier syntax, Pythonic data access, and help prevent SQL injection.
  • Drawbacks include added dependencies and less flexibility for complex SQL queries.

Web Scraping: Beautiful Soup

  • Beautiful Soup parses and extracts data from HTML and XML documents easily.
  • Always check the website’s robots.txt file to ensure web scraping is allowed.
  • Python has built-in tools (urllib.robotparser) to check scraping permissions.

Mathematics: SymPy

  • SymPy solves algebraic equations symbolically, useful for engineers and scientists.
  • You can define symbols and equations, then solve for unknowns symbolically.
  • Limited type annotations may cause issues in IDEs.

Project Templates: Cookiecutter

  • Cookiecutter generates project scaffolding from templates to reduce boilerplate code.
  • There are many templates available, but choosing the right one can be time-consuming.
  • Using templates may reduce your understanding of the project’s structure.

Data Serialization: Pickle

  • Pickle serializes and deserializes Python objects, storing them as binary files.
  • Useful for saving program state or sharing objects.
  • Loading Pickle files can run arbitrary code, so avoid untrusted files for security.

Game Development: Pygame

  • Pygame allows building simple 2D games with Python, offering event loops and drawing functions.
  • Suitable for basic games but not ideal for large-scale or AAA game development.

Data Visualization: Missingno

  • Missingno visualizes missing data in datasets, aiding in data cleaning and preprocessing.
  • It produces plots showing where data is missing or present.

HTML Templating: Jinja2

  • Jinja2 is a flexible template engine for generating HTML or AI prompts.
  • Supports variables, conditions, loops, and nested objects in templates.

File Monitoring: Watchdog

  • Watchdog monitors file system changes and triggers actions when files are modified.
  • Useful for automating tasks based on file changes.

Functional Programming: Returns

  • Returns introduces monads and pattern matching for safer, more functional error handling.
  • Provides Maybe and Result types for handling errors without exceptions.

Data Conversion: Numerizer

  • Numerizer converts written numbers in text to numerical values (e.g., "twenty one" → 21).
  • Useful for processing human-readable numeric data.

Object Management: Box

  • Box makes dictionary data accessible with dot notation, simulating object-like behavior.
  • Lacks type annotations, potentially causing IDE type errors.

Functional Pipelines: Python-Pipe

  • Python-Pipe enables functional pipeline syntax with the pipe operator for chaining operations.
  • Helps compose readable, sequential data transformations.

UI Creation: NiceGUI

  • NiceGUI builds web-based user interfaces for Python apps with interactive controls and dashboards.
  • Launches a local web server for browser-based UIs.

Screenshot to Code

  • ScreenshotToCode uses deep learning to convert UI screenshots into HTML and CSS code.
  • Useful for quickly replicating website designs.

Key Terms & Definitions

  • ORM (Object Relational Mapper) — maps database tables to Python classes for easier data manipulation.
  • Serialization — converting an object into a format for storage or transmission.
  • Monads — design pattern for handling computations with context, commonly used in functional programming.
  • Templating Engine — software that generates documents from templates with dynamic content.

Action Items / Next Steps

  • Explore at least one package relevant to your work and try a sample project.
  • Check documentation for each package before use, especially for security considerations.
  • Consider homework or further reading on Python package documentation and project scaffolding.