Helpful functions for Python
domdf-python-tools is a Python library providing a comprehensive collection of helpful functions and tools for various development tasks, encompassing utilities for strings, paths, dates, and more. It is actively maintained with a regular release cadence, primarily focusing on minor and patch updates. The current version is 3.10.0.
Warnings
- breaking The license changed from LGPLv3+ to MIT License starting with version 3.0.0. Users upgrading from versions prior to 3.0.0 should be aware of this license change.
- gotcha The PyPI package name is `domdf-python-tools` (with hyphens), but the Python import name uses underscores: `domdf_python_tools`. This is a common pattern but can trip up new users.
- gotcha Some versions of `domdf-python-tools` (e.g., prior to a fix in Fedora's `3.9.0-7.fc43` package) have exhibited compatibility issues with newer Python versions, specifically Python 3.14, leading to `AssertionError` in tests related to string processing (e.g., `test_words.py::test_alpha_sort`).
Install
-
pip install domdf-python-tools
Imports
- true_str
from domdf_python_tools.utils import true_str
- StringList
from domdf_python_tools.stringlist import StringList
- PathPlus
from domdf_python_tools.paths import PathPlus
Quickstart
from domdf_python_tools.utils import true_str
from domdf_python_tools.stringlist import StringList
from domdf_python_tools.paths import PathPlus
import os
# Using a utility function
print(f"Converting 'True' to boolean: {true_str('True')}")
print(f"Converting 'false' to boolean: {true_str('false')}")
# Using StringList for custom delimited output
my_list = StringList([1, 2, 3], delimiter="|")
print(f"Custom delimited list: {my_list}")
# Using PathPlus for extended path operations
current_dir = PathPlus(os.getcwd())
print(f"Current directory path (PathPlus): {current_dir}")
print(f"Is current directory a directory? {current_dir.is_dir()}")