CONstrained CONtainers: immutable and append-only container subclasses and utilities.
Project description
concon (CONstrained CONtainers) provides usefully constrained container subtypes:
frozenlist
frozendict
frozenset - (Note this is a synonym for the builtin frozenset for completeness.)
appendonlylist
appendonlydict
appendonlyset
Examples
>>> import concon
>>> d = concon.appendonlydict()
>>> d['foo'] = 'bar'
>>> d.items()
[('foo', 'bar')]
>>> d['foo'] = 'quz'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/n/virtualenvs/default/lib/python2.7/site-packages/concon.py", line 102, in setitem_without_overwrite
raise OverwriteError(key, value, d[key])
concon.OverwriteError: Attempted overwrite of key 'foo' with new value 'quz' overwriting old value 'bar'
>>> l = concon.frozenlist(['a', 'b', 'c'])
>>> l[1]
'b'
>>> l.append(42)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/n/virtualenvs/default/lib/python2.7/site-packages/concon.py", line 37, in blocked_method
raise cls(self, method.__name__, a, kw)
concon.ConstraintError: Attempt to call ['a', 'b', 'c'].append (42,) {} violates constraint.
>>> l[2] = 42
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/n/virtualenvs/default/lib/python2.7/site-packages/concon.py", line 37, in blocked_method
raise cls(self, method.__name__, a, kw)
concon.ConstraintError: Attempt to call ['a', 'b', 'c'].__setitem__ (2, 42) {} violates constraint.
Upgrading
Note, the old versioning scheme included distributed packages with versions of the format 1.<LONG HEXADECIMAL HASH>. The latest release is 2.0 which should supercede the previous versioning scheme for setuptools-style dependency requirements. New releases will always use PEP 0440 compliant versions.
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
File details
Details for the file concon-2.0.tar.gz.
File metadata
- Download URL: concon-2.0.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
09d47a418e018a892fbb27d5f7fd45d29c5f75332efb8093b4d39c5ec5605d76
|
|
| MD5 |
d87ba68c3b0f5819ba572206abbd0ec5
|
|
| BLAKE2b-256 |
a76e7b4277c4e4e1a74d636306e3ef0b9147f1898a5ef30750b9a7ff053f21b2
|