Metadata-Version: 2.4
Name: sconst
Version: 1.0.0
Summary: Immutable constant types for Python.
Author-email: Evan Yang <quantbit@126.com>
License: MIT License
        
        Copyright (c) 2026 Evan Yang aiwonderland
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/aiwonderland/sconst
Project-URL: Repository, https://github.com/aiwonderland/sconst
Project-URL: Issues, https://github.com/aiwonderland/sconst/issues
Keywords: constants,immutable,readonly,descriptor
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.0
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# sconst

Immutable constant types for Python.

## Installation

```bash
pip install sconst
```

## Usage

### Constant types

```python
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:

```python
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](LICENSE)
