Skip to main content

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.

Project details


Download files

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

Files for concon, version 1.39f12a0e86e50b0895d998c8c5b8d00e80d7abb6
Filename, size File type Python version Upload date Hashes
Filename, size concon-1.39f12a0e86e50b0895d998c8c5b8d00e80d7abb6.tar.gz (4.5 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page