bx_py_utils

raw JSON →
118 verified Fri May 01 auth: no python

A collection of various Python utility functions, currently at version 118. It provides helpers for CLI, color output, dictionaries, Django, HTML, and more. Requires Python >= 3.11. Released sporadically on PyPI.

pip install bx-py-utils
error ModuleNotFoundError: No module named 'bx_py_utils'
cause Package not installed or installed under a different name (e.g., 'bx-py-utils' with hyphens).
fix
Run pip install bx-py-utils. Ensure your environment has the package.
error AttributeError: module 'bx_py_utils' has no attribute 'red_sym'
cause Wrong import path or older version where red_sym was in a submodule.
fix
Update to latest version: pip install -U bx-py-utils. Then use from bx_py_utils import red_sym.
error ImportError: cannot import name 'BaseTest' from 'bx_py_utils'
cause BaseTest was moved to bx_py_utils.test_utils in a breaking change.
fix
Change import to from bx_py_utils.test_utils import BaseTest.
gotcha The version number is an integer (118) incremented for every release, not semantic versioning. Breaking changes can occur at any minor bump.
fix Pin to a specific version and review changelog before upgrading.
gotcha Some utilities rely on optional dependencies like Django, colorama. Missing them causes ImportError at runtime if you directly access submodules.
fix Install extra dependencies: pip install bx-py-utils[django,colorama] or handle missing imports gracefully.
deprecated The function `bx_py_utils.HTMLRenderer` is deprecated in favor of Django's native template rendering.
fix Use Django's `django.template.loader.render_to_string` instead.

Import and use color utilities. The NO_COLOR environment variable disables ANSI coloring.

from bx_py_utils import red_sym, green_sym

print(red_sym('Error'))   # prints red colored text with '✘' symbol
print(green_sym('OK'))    # prints green colored text with '✔' symbol

# Output without colors (e.g., in CI):
import os
os.environ['NO_COLOR'] = '1'
print(red_sym('still plain text'))  # no coloring