{"library":"boltons","title":"boltons","description":"boltons is a collection of over 250 pure-Python utilities designed to fill gaps in Python's standard library. It provides high-performance data structures and convenient functions for common tasks across various domains like file systems, iteration, caching, and time management. The library maintains an active development status, with major releases occurring roughly annually, interspersed with minor updates bringing enhancements and bug fixes. [1, 4, 5, 6, 8, 11]","status":"active","version":"25.0.0","language":"en","source_language":"en","source_url":"https://github.com/mahmoud/boltons","tags":["utilities","stdlib-enhancements","collections","functional-programming","files","iteration","caching"],"install":[{"cmd":"pip install boltons","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"A dictionary subclass that remembers insertion order and allows multiple values per key.","symbol":"OrderedMultiDict","correct":"from boltons.dictutils import OrderedMultiDict"},{"note":"For recursively traversing and transforming nested data structures.","symbol":"remap","correct":"from boltons.iterutils import remap"},{"note":"A dictionary-like Least Recently Used (LRU) cache.","symbol":"LRU","correct":"from boltons.cacheutils import LRU"},{"note":"Creates a directory and any necessary parent directories, similar to 'mkdir -p'.","symbol":"mkdir_p","correct":"from boltons.fileutils import mkdir_p"}],"quickstart":{"code":"from boltons.dictutils import OrderedMultiDict\n\n# Initialize the OrderedMultiDict\nomd = OrderedMultiDict()\n\n# Add items - supports multiple values for a single key\nomd['fruit'] = 'apple'\nomd['fruit'] = 'banana'\nomd['vegetable'] = 'carrot'\n\n# Access all values for a key\nprint(f\"All fruits: {omd['fruit']}\")\n# Expected output: All fruits: ['apple', 'banana']\n\n# Get the first value for a key\nprint(f\"First fruit: {omd.get_first('fruit')}\")\n# Expected output: First fruit: apple\n\n# Iterate through all key-value pairs (maintaining insertion order)\nprint(\"\\nAll items:\")\nfor key, value in omd.items():\n    print(f\"{key}: {value}\")\n# Expected output:\n# All items:\n# fruit: apple\n# fruit: banana\n# vegetable: carrot","lang":"python","description":"This example demonstrates the `OrderedMultiDict` from `boltons.dictutils`, which allows storing multiple values for a single key while preserving insertion order. It's useful for scenarios where a standard dictionary's behavior is insufficient. [5, 6]"},"warnings":[{"fix":"Upgrade to Python 3.7+ or pin boltons to a version less than 24.0.0 (e.g., `pip install 'boltons<24.0.0'`).","message":"Version 24.0.0 dropped support for Python 2. boltons is now Python 3 only (3.7+). If you are on Python 2, you must pin your dependency to `boltons<24.0.0`.","severity":"breaking","affected_versions":">=24.0.0"},{"fix":"Replace `datetime.utcnow()` with `datetime.now(timezone.utc)`.","message":"In version 25.0.0, the use of `datetime.utcnow()` was replaced internally due to its deprecation in Python 3.12. While this was an internal change, direct usage of `utcnow()` in user code, especially when interacting with boltons' `timeutils`, should be updated to `datetime.now(timezone.utc)` for future compatibility and best practice.","severity":"deprecated","affected_versions":">=25.0.0"},{"fix":"Consider copying individual modules into your project if you only need a small subset of functionality or prefer zero dependencies for those specific utilities. Refer to the 'Integration' section of the boltons documentation for more details. [7, 11]","message":"Due to its nature as a collection of self-contained utilities with no external dependencies, boltons supports 'vendorization' of individual modules. If the full library is too large for your project, or for tighter integration, you can copy specific modules (e.g., `fileutils.py`) directly into your project.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-06T00:00:00.000Z","next_check":"2026-07-05T00:00:00.000Z"}