This module allows to save and load objects in PNML. The standard is correctly handled for low-level nets, ie, nets with only True guards and black tokens. However, module snakes.pnml was actually created long before the PNML standard was extended to handle high-level nets (in particular coloured variants) and so the standard is not respected in this case. Consequently, in the following, we abuse the term PNML for the XML produced and read by SNAKES.

Warning: this module will be replaced in a future version of SNAKES, so its documentation will be kept minimal.

Function dumps

def dumps (obj) :

Dump an object to a PNML string, any Python object may be serialised this way (resorting to pickling when the object does not support serialisation to PNML).

>>> print(dumps(42))
<?xml version="1.0" encoding="utf-8"?>
<pnml>
 <object type="int">
  42
 </object>
</pnml>
Call API

Function loads

def loads (source, plugins=[]) :

Load an object from a PNML string

>>> loads(dumps(42))
42
Call API