Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #62258 > unrolled thread
| Started by | smilesonisamal@gmail.com |
|---|---|
| First post | 2013-12-17 19:22 -0800 |
| Last post | 2013-12-17 20:32 -0800 |
| Articles | 5 — 5 participants |
Back to article view | Back to comp.lang.python
Logger module in python smilesonisamal@gmail.com - 2013-12-17 19:22 -0800
Re: Logger module in python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-18 03:27 +0000
Re: Logger module in python Paul Smith <paul@mad-scientist.net> - 2013-12-17 22:46 -0500
Re: Logger module in python Roy Smith <roy@panix.com> - 2013-12-17 22:54 -0500
Re: Logger module in python rusi <rustompmody@gmail.com> - 2013-12-17 20:32 -0800
| From | smilesonisamal@gmail.com |
|---|---|
| Date | 2013-12-17 19:22 -0800 |
| Subject | Logger module in python |
| Message-ID | <fabe3b07-3d2f-48f2-9e56-2fdebff39175@googlegroups.com> |
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. Can anybody help me in this regard? Regards Pradeep
[toc] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2013-12-18 03:27 +0000 |
| Message-ID | <mailman.4323.1387337264.18130.python-list@python.org> |
| In reply to | #62258 |
On 18/12/2013 03:22, smilesonisamal@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. > > Can anybody help me in this regard? > > Regards > Pradeep > http://docs.python.org/3/library/logging.html -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence
[toc] | [prev] | [next] | [standalone]
| From | Paul Smith <paul@mad-scientist.net> |
|---|---|
| Date | 2013-12-17 22:46 -0500 |
| Message-ID | <mailman.4329.1387338793.18130.python-list@python.org> |
| In reply to | #62258 |
On Wed, 2013-12-18 at 03:27 +0000, Mark Lawrence wrote: > On 18/12/2013 03:22, smilesonisamal@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. > > http://docs.python.org/3/library/logging.html That's not what the OP wants. Pradeep, if you want to dump data for debugging take a look at the pprint module; for example: http://docs.python.org/3.3/library/pprint.html If you want to store Python objects in files and read them later, most people seem to use pickle for that: http://docs.python.org/3.3/library/pickle.html Others translate into another format. See this SO question for some other suggestions: http://stackoverflow.com/questions/2540567/is-there-a-python-equivalent-to-perls-datadumper
[toc] | [prev] | [next] | [standalone]
| From | Roy Smith <roy@panix.com> |
|---|---|
| Date | 2013-12-17 22:54 -0500 |
| Message-ID | <roy-C4C5F7.22543117122013@news.panix.com> |
| In reply to | #62258 |
In article <fabe3b07-3d2f-48f2-9e56-2fdebff39175@googlegroups.com>, smilesonisamal@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.
[toc] | [prev] | [next] | [standalone]
| From | rusi <rustompmody@gmail.com> |
|---|---|
| Date | 2013-12-17 20:32 -0800 |
| Message-ID | <51304f70-0c10-4de6-bce8-375aced049c4@googlegroups.com> |
| In reply to | #62258 |
On Wednesday, December 18, 2013 8:52:11 AM UTC+5:30, smileso...@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. Assuming you are looking for a serialization format: If efficiency, easily-at-hand, standard are important then pickle better than json better than yaml If however readability of the output (as the word 'log' suggests) is desired its the other way round: yaml is the most readable, pickle is utterly unreadable
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web