Logger module in python
Roy Smith
roy at panix.com
Tue Dec 17 22:54:31 EST 2013
In article <fabe3b07-3d2f-48f2-9e56-2fdebff39175 at googlegroups.com>,
smilesonisamal at gmail.com wrote:
> Hi,
> I am a newbie in python. I am looking for a existing module which I can
> import in my program to log the objects to a file?
>
> I know there is a module Data::Dumper in perl which dumps the objects to
> file. But not sure about python.
You're talking about what's known as serializing an object. Taking the
in-memory representation and turning it into something that can be
written into a network connection or into a file, then read back in, and
turned back into an in-memory object.
The standard way to do this in Python is pickle
(http://docs.python.org/2/library/pickle.html). Depending on the type
of data you have, you might want to use JSON encoding instead
(http://docs.python.org/2/library/json.html), but pickle is probably the
most similar to Data::Dumper.
More information about the Python-list
mailing list