A PDict is a dictionary that is mostly like the built-in Python dictionary type:
>>> from pysistence import make_dict
>>> d = make_dict(foo='bar')
>>> d
{'foo': 'bar'}
The main difference is that this dictionary is immutable:
>>> d['asdf'] = 'jkl;'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "persistent_dict.py", line 22, in not_implemented_method
raise NotImplementedError, 'Cannot set values in a PDict'
NotImplementedError: Cannot set values in a PDict
>>> del d['foo']
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "persistent_dict.py", line 22, in not_implemented_method
raise NotImplementedError, 'Cannot set values in a PDict'
NotImplementedError: Cannot set values in a PDict
Just like the Expando, you can make copies using the without and using methods:
>>> d2 = d.using(asdf='jkl;')
>>> d2
{'foo': 'bar', 'asdf': 'jkl;'}
>>> d3 = d2.without('foo')
>>> d3
{'asdf': 'jkl;'}
See also
Build a PDict instance. See the documentation for make_dict() for more information.