nCompass Tools Library
Project description
nc_utils
nCompass Library
A Python library providing immutable objects and traits for building robust applications.
Installation: pip install ncompasslib
Basic Usage:
- Creating an Immutable Object: The Immutable class prevents attributes from being modified after they are first set.
from ncompasslib.immutable import Immutable
class MyClass(Immutable): def init(self): super().init() self.value = 42
obj = MyClass() obj.value # Returns 42 obj.value = 43 # Raises RuntimeError: Cannot change state once created
- Using the Mutate Decorator: When you need to modify an immutable object in a controlled way, use the mutate decorator.
from ncompasslib.immutable import Immutable, mutate
class Counter(Immutable): def init(self): super().init() self.count = 0
@mutate
def increment(self):
self.count += 1
- Creating Traits: Traits are abstract base classes that are also immutable.
from ncompasslib.trait import Trait
class MyTrait(Trait): def init(self): super().init() self.trait_value = "example"
Features:
- Immutable objects with controlled mutation
- Trait system for creating abstract interfaces
- Python 3.12+ support
- Comprehensive test suite
For more information, visit: https://github.com/nCompass-tech/ncompasslib
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ncompasslib-0.0.1.tar.gz.
File metadata
- Download URL: ncompasslib-0.0.1.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e6b0f223fd61e35595ab56836437c8e4bc6c8ff615d772fd9f7890b470325e9
|
|
| MD5 |
7c8d19d126634fc69456519808cf5264
|
|
| BLAKE2b-256 |
73b1125144f5c2c1d73aadc6cf3c01c86382ec6ef0377b5693464c60baa5af2a
|
File details
Details for the file ncompasslib-0.0.1-py3-none-any.whl.
File metadata
- Download URL: ncompasslib-0.0.1-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21531055b915127f6c97bcea322982a770cce9aa51827316d8bfe1387389b441
|
|
| MD5 |
ffd33a64a3948a21585ea1caa66d4dc1
|
|
| BLAKE2b-256 |
d4ec9be4a462c556c0240c43369813134adfed86c8c7b1b0c043974279e78caa
|