cutcutcodec.utils
Pythonic tools.
Classes
For share memory inside the current session. |
Functions
Return the extra compilation rules. |
|
Return the absolute project root folder. |
Details
- class cutcutcodec.utils.MetaSingleton[source]
For share memory inside the current session.
Notes
The arguments needs to be hashable.
Examples
>>> from cutcutcodec.utils import MetaSingleton >>> class A: ... pass ... >>> class B(metaclass=MetaSingleton): ... pass ... >>> class C(metaclass=MetaSingleton): ... def __init__(self, *args, **kwargs): ... self.args = args ... self.kwargs = kwargs ... >>> A() is A() False >>> B() is B() True >>> C(0) is C(0) True >>> C(0) is C(1) False >>>
- cutcutcodec.utils.get_project_root() Path[source]
Return the absolute project root folder.
Examples
>>> from cutcutcodec.utils import get_project_root >>> root = get_project_root() >>> root.is_dir() True >>> root.name 'cutcutcodec' >>> sorted(p.name for p in root.iterdir()) ['__init__.py', '__main__.py', ...] >>>