PyMiscUtils
PyMiscUtils (installed via `pip install pymiscutils`) provides a collection of miscellaneous Python utilities, including context managers like `Timer` and `Suppressor`, a `NestedParser` for string parsing, and various helper classes for introspection, environment variables, and version management. The library is currently at version 0.3.14 and is under active development with frequent minor releases, though the API is subject to change.
Warnings
- breaking The library is explicitly stated as being under active development, and its API is subject to significant changes that may break existing code in future versions. Use with caution in production environments where API stability is critical.
- gotcha The PyPI package name is `pymiscutils`, but the actual top-level Python import package is `miscutils`. Attempting to `import pymiscutils` will result in an `ModuleNotFoundError`.
- gotcha Many useful classes and functions are nested within specific submodules (e.g., `miscutils.context_managers`, `miscutils.string_manipulation`, `miscutils.system`). Direct imports from `miscutils` for these specific components will often fail.
Install
-
pip install pymiscutils
Imports
- Timer
from miscutils.context_managers import Timer
- NestedParser
from miscutils.string_manipulation import NestedParser
- EnvironmentVariables
from miscutils.system import EnvironmentVariables
Quickstart
import time
from miscutils.context_managers import Timer
def long_running_task():
print("Starting a long task...")
time.sleep(1.5)
print("Task finished.")
with Timer('My Task'):
long_running_task()