nr-util
nr-util is a general-purpose Python utility library. It aims to provide common helper functions and tools for various programming tasks. The current version is 0.8.12, released on June 20, 2022. Its release cadence appears irregular, based on PyPI upload history.
Common errors
-
ModuleNotFoundError: No module named 'nr.util.some_module'
cause Attempting to import a submodule or utility that does not exist, or using an incorrect import path.fixConsult the official GitHub repository for the correct module structure and available utilities. Verify the exact import path for the desired functionality. For example, some utilities might be under `nr.util.fs` or `nr.util.digraph`. -
TypeError: 'module' object is not callable (when trying to use a utility directly after `import nr.util`)
cause The user is trying to call the top-level `nr.util` module directly as a function or object, rather than importing a specific utility function or class from it.fixEnsure you are importing specific components from `nr.util` or its submodules. For example, instead of `import nr.util; nr.util.some_function()`, use `from nr.util.some_module import some_function; some_function()`.
Warnings
- breaking The library uses 0.x.y versioning, meaning minor version increments (e.g., 0.8.x to 0.9.x) may introduce breaking API changes without a major version bump. Users should review changelogs carefully when upgrading.
- gotcha The package name on PyPI is 'nr-util', but imports typically use 'nr.util' (e.g., `from nr.util import ...`). This discrepancy is common but can be confusing for new users.
Install
-
pip install nr-util
Imports
- anything
from nr.util import anything
Quickstart
from nr.util.digraph import Digraph
g = Digraph()
g.add_node('A')
g.add_node('B')
g.add_node('C')
g.add_edge('A', 'B')
g.add_edge('B', 'C')
print(f"Nodes: {g.nodes}")
print(f"Edges: {g.edges}")
print(f"Is DAG: {g.is_dag()}")