Skip to main content

sconst

Immutable constant types for Python.

Installation

pip install sconst

Usage

Constant types

from sconst import IntConstant, StrConstant, ListConstant, TupleConstant

x = IntConstant(42)
print(x.value)   # 42
x.value = 10     # raises ChangeConstError

s = StrConstant("hello")
print("ell" in s)  # True
s + " world"       # raises ChangeConstError

items = ListConstant([1, 2, 3])
print(items[0])    # 1
for item in items: # iteration works
    print(item)

coords = TupleConstant((10, 20))
print(len(coords)) # 2

const_property descriptor

A read-only property whose value is computed once and then frozen:

from sconst import const_property

class Config:
    @const_property
    def max_retries(self):
        return 5

cfg = Config()
cfg.max_retries        # 5
cfg.max_retries = 10   # raises ChangeConstError
del cfg.max_retries    # raises DeleteConstError

Classes

Class Description
BaseConstant Base class for all constant wrappers
IntConstant Constant integer — blocks arithmetic and mutation
StrConstant Constant string — blocks +, *, and item assignment
IterableConstant Base for iterable constants — supports iteration, indexing, len(), and in
ListConstant Constant list
TupleConstant Constant tuple

Exceptions

Exception Raised when
SconstException Base exception for all sconst errors
ChangeConstError An attempt is made to modify a constant
DeleteConstError An attempt is made to delete a constant attribute

License

MIT

Metadata

Release files for sconst 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sconst 1.0.0
File Size Uploaded Provenance
sconst-1.0.0.tar.gz 6.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for sconst 1.0.0
File Interpreter ABI Platform
sconst-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 13.2 kB

Release files / sconst-1.0.0.tar.gz

Download URL sconst-1.0.0.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
6c25520a725a22458826a201b3cba15b3e0474ca6415203a422f800500ac9828
BLAKE2b-256 checksum
How to use checksums
6cf8322eeae3535c9e9bec268eb485670f4983bbe15238ada93c2cf039e40b0d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release files / sconst-1.0.0-py3-none-any.whl

Download URL sconst-1.0.0-py3-none-any.whl
Size 6.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c5a0d672114980b5a4291cd14d4d46f62dae68e247c7502636f28a20679cd98f
BLAKE2b-256 checksum
How to use checksums
5a854723736c08054de8b0e41a0352cd010c95c6a6cb73d66029052f59be15c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Security for sconst 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page