Skip to main content

ncompasslib

nCompass Library

A Python library providing immutable objects and traits for building robust applications.

Installation:

pip install ncompasslib

Basic Usage:

1. 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

2. 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

3. 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.11+ support
  • Comprehensive test suite

For more information, visit: https://github.com/nCompass-tech/ncompasslib

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ncompasslib-0.0.1.post7.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ncompasslib-0.0.1.post7-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file ncompasslib-0.0.1.post7.tar.gz.

File metadata

  • Download URL: ncompasslib-0.0.1.post7.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for ncompasslib-0.0.1.post7.tar.gz
Algorithm Hash digest
SHA256 07774d477206e1b212a4238a5df19aa679241eaee0cda70b1a4f450999b3b122
MD5 0644e976d5fbf9d8fb7d0e580f92ee7d
BLAKE2b-256 b564c6e03fbaca7730e9fd7375dbbaad2f34657504e60c96744abd087b4e989e

See more details on using hashes here.

File details

Details for the file ncompasslib-0.0.1.post7-py3-none-any.whl.

File metadata

File hashes

Hashes for ncompasslib-0.0.1.post7-py3-none-any.whl
Algorithm Hash digest
SHA256 70b3a41807d31ac89e1e46423e1fd83c0084602bf983a4fe1543530c07bd149e
MD5 241f40a2221bee31fab754f1f4c8cf40
BLAKE2b-256 d243e33aa3ea9c660ea7f69259a524e324b8a2fa9771e7c69311c8b99af02bd1

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.1.post7 This release

2 files

0.0.1.post5

2 files

0.0.1.post4

2 files

0.0.1.post3

2 files

0.0.1.post2

2 files

0.0.1.post1

2 files

0.0.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page