{"id":5091,"library":"utils","title":"pyutils (haaksmash)","description":"A grab-bag of utility functions and objects for Python, developed by haaksmash. This library provides common, oft-repeated functionalities across various modules like enums, math, dictionaries, lists, booleans, dates, and objects. It is currently at version 1.0.2 and appears to have a stable, though not rapid, release cadence.","status":"active","version":"1.0.2","language":"en","source_language":"en","source_url":"http://github.com/haaksmash/pyutils","tags":["utilities","enums","dates","data structures","helpers"],"install":[{"cmd":"pip install utils","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"note":"Imports the custom Enum implementation.","symbol":"enum","correct":"from utils import enum"},{"note":"Imports the TimePeriod class for date range manipulation.","symbol":"TimePeriod","correct":"from utils.dates import TimePeriod"},{"note":"Example of importing a specific utility function from a submodule.","symbol":"flatten","correct":"from utils.lists import flatten"}],"quickstart":{"code":"from datetime import date\nfrom utils import enum\nfrom utils.dates import TimePeriod\n\nclass Colors(enum.Enum):\n    RED = 0\n    GREEN = 1\n\n# Defining an Enum class allows you to specify a few\n# things about the way it's going to behave.\nclass Options:\n    frozen = True # can't change attributes\n    strict = True # can only compare to itself\n\n# Usage of Enum\nprint(f\"Red enum: {Colors.RED}\")\nprint(f\"Is Colors.RED == 0? {Colors.RED == 0}\")\n\n# Usage of TimePeriod\ntime_period = TimePeriod(date(2023, 1, 1), date(2023, 1, 31))\nprint(f\"Time period: {time_period}\")\nprint(f\"Is 2023-01-15 in period? {date(2023, 1, 15) in time_period}\")","lang":"python","description":"This quickstart demonstrates the core functionality of the `enum` module for creating robust enumerations and the `TimePeriod` class from the `dates` module for handling date ranges. It showcases how to define an enum with options like `frozen` and `strict`, and how to check if a date falls within a defined time period."},"warnings":[{"fix":"Respect the immutability of frozen enum members. If mutability is required, set `frozen = False` in the `Options` class or avoid using the `frozen` option.","message":"When defining enums using `utils.enum.Enum` with `Options.frozen = True`, enum members become immutable. Attempting to reassign a value to an enum member (e.g., `Colors.RED = 2`) will raise a `TypeError`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Be explicit with imports (e.g., `from utils import enum` instead of `import utils` if only specific submodules are needed). Consider importing with an alias (e.g., `import utils as haak_utils`) in projects with potential name clashes.","message":"Due to the generic name 'utils', there is a potential for import conflicts with other packages that might define a 'utils' module or with local project modules also named 'utils'.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Monitor the GitHub repository for any new releases or activity. Consider contributing fixes or new features if critical to your project, or explore actively maintained alternatives if the lack of updates becomes an issue.","message":"The GitHub repository's last significant commit was over a year ago, suggesting the library may be in maintenance mode with infrequent updates. Users should verify active development if new features or urgent bug fixes are critical.","severity":"deprecated","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}