Is there a Python module that can be used in the same way as Perl\'s Data::Dumper module?
Edit: Sorry, I should have been clearer. I was mainly afte
For serialization, there are many options.
One of the best is JSON, which is a language-agnostic standard for serialization. It is available in 2.6 in the stdlib json module and before that with the same API in the third-party simplejson
module.
You do not want to use marshal
, which is fairly low-level. If you wanted what it provides, you would use pickle.
I avoid using pickle the format is Python-only and insecure. Deserializing using pickle can execute arbitrary code.
pickle
, you want to use the C implementation thereof. (Do import cPickle as pickle
.)For debugging, you usually want to look at the object's repr
or to use the pprint
module.