Re: Logger module in python
Original Message - > 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 > -- > https://mail.python.org/mailman/listinfo/python-list There's a (better) alternative to pickle: serpent. https://pypi.python.org/pypi/serpent I've been told it was a standard module in python 3, I'm not sure though. Basically it's pickle without the security issue and a readable text format. JM -- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you. -- https://mail.python.org/mailman/listinfo/python-list
Re: Logger module in python
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 -- https://mail.python.org/mailman/listinfo/python-list
Re: Logger module in python
On 18/12/2013 03:36, Cameron Simpson wrote: On 18Dec2013 03:27, Mark Lawrence wrote: On 18/12/2013 03:22, smilesonisa...@gmail.com wrote: 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? http://docs.python.org/3/library/logging.html No, Mark, no. The pickle and pickletools modules sound like what he wants. Cheers, So I've already been told :) I really must get out of the habit of posting at 3:30 in the morning when absolutely shattered, it's more of a hindrance than a help :( -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: Logger module in python
On 18Dec2013 03:27, Mark Lawrence wrote: > On 18/12/2013 03:22, smilesonisa...@gmail.com wrote: > > 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? > > http://docs.python.org/3/library/logging.html No, Mark, no. The pickle and pickletools modules sound like what he wants. Cheers, -- Tomkin Coleman (tcol...@nv7.uswnvg.com) wrote: | Well, yes, get the bike but BEWARE!! | At first, you will just want to get, like, a 250 Rebel, just for commuting | and maybe a little fun, but you will wind up buying a 550, (just in case you | want to tour), and then you will stop paying any attention to the theatre | company you are working with and the graduate school you are attending, and | then you will spend all your summers touring and riding around with your | newfound biking buddies, and then you will find that you have got a real job | just so you can buy the bike of your dreams and pretty soon you will find | that your entire life has centered around your monster bike and you can only | date women who love bikes and hang with buddies who love bikes and work at a | job that supports your lifestyle and you will be incredibly happy, but always | very greasy. S! The meaning of life is supposed to be a SECRET! :-) - Bob Larson..DoD#1711..b...@honshu.ho.att.com..1994 Suzuki RF600R -- https://mail.python.org/mailman/listinfo/python-list
Re: Logger module in python
In article , smilesonisa...@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. -- https://mail.python.org/mailman/listinfo/python-list
Re: Logger module in python
On Wed, 2013-12-18 at 03:27 +, Mark Lawrence wrote: > On 18/12/2013 03:22, smilesonisa...@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 -- https://mail.python.org/mailman/listinfo/python-list
Re: Logger module in python
On 18/12/2013 03:22, smilesonisa...@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 -- https://mail.python.org/mailman/listinfo/python-list