networkx.readwrite.gml.literal_stringizer

literal_stringizer(value)[source]

Convert a value to a Python literal in GML representation.

Parameters

value (object) – The value to be converted to GML representation.

Returns

rep – A double-quoted Python literal representing value. Unprintable characters are replaced by XML character references.

Return type

string

Raises

ValueError – If value cannot be converted to GML.

Notes

literal_stringizer is largely the same as repr in terms of functionality but attempts prefix unicode and bytes literals with u and b to provide better interoperability of data generated by Python 2 and Python 3.

The original value can be recovered using the networkx.readwrite.gml.literal_destringizer() function.