473,394 Members | 1,797 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Readable Persistance?

I'm trying to write programs that make use of a lot of dynamic
structures. To aid in debugging and data extraction, I'd like to persist
these objects in a form that's readable, but one that also preserves
handles (ie for lambda expressions, dictionaries, lists, etc). Using the
pickle module, I can more-or-less accomplish the latter, but not the
former. YAML can accomplish the former to some degree, but still can't
represent handles. I understand the inherent difficulties in
representing complex objects in a human readable format, but is there
any way to do this with Python? Any help is appreciated.
Jul 18 '05 #1
4 1444
Chris S. wrote:
I'm trying to write programs that make use of a lot of dynamic
structures. To aid in debugging and data extraction, I'd like to persist
these objects in a form that's readable, but one that also preserves
handles (ie for lambda expressions, dictionaries, lists, etc). Using the
pickle module, I can more-or-less accomplish the latter, but not the
former. YAML can accomplish the former to some degree, but still can't
represent handles. I understand the inherent difficulties in
representing complex objects in a human readable format, but is there
any way to do this with Python? Any help is appreciated.


Never actually tried it, but isn't there a xml-variant for pickling? Maybe
that helps you.

Regards,

Diez
Jul 18 '05 #2
Diez B. Roggisch wrote:
Chris S. wrote:

I'm trying to write programs that make use of a lot of dynamic
structures. To aid in debugging and data extraction, I'd like to persist
these objects in a form that's readable, but one that also preserves
handles (ie for lambda expressions, dictionaries, lists, etc). Using the
pickle module, I can more-or-less accomplish the latter, but not the
former. YAML can accomplish the former to some degree, but still can't
represent handles. I understand the inherent difficulties in
representing complex objects in a human readable format, but is there
any way to do this with Python? Any help is appreciated.

Never actually tried it, but isn't there a xml-variant for pickling? Maybe
that helps you.

Regards,

Diez

http://gnosis.cx/download/Gnosis_Utils-current.tar.gz

according to my tests it works nicely as a pickle replacement that is at
least a bit more readable than plain old pickle. Not sure if I'd want to
edit it by hand though..

/Simon

Jul 18 '05 #3
"Chris S." <ch*****@NOSPAMudel.edu> writes:
I'm trying to write programs that make use of a lot of dynamic
structures. To aid in debugging and data extraction, I'd like to
persist these objects in a form that's readable, but one that also
preserves handles (ie for lambda expressions, dictionaries, lists,
etc).


Can you clarify what you might mean by "debugging and data extraction"?

The reason I ask is that if you're primarily concerned with the
ability to access the data easily outside of the program that
generated it, then have you considered just interatively loading your
picking file and performing whatever manipulations you might want?

That is, if pickle satisfies your need for the persistence of the data
structures themselves, perhaps the readability of the raw pickle file
need not be a problem if you consider just using Python to load that
file in when you need to examine it. You could always interactively
(or with small scripts if you do repetitive operations) then dump
selected portions of the data to more parseable flat text files for
use with other tools if necessary, while not losing any of the
richness of the original data structure.

I know that I've done this numerous times in the past (both with
pickle files as well as with ZODB databases) as a way to examine
stored program state in an interactive manner outside of the original
application.

-- David
Jul 18 '05 #4
David Bolen wrote:
"Chris S." <ch*****@NOSPAMudel.edu> writes:

I'm trying to write programs that make use of a lot of dynamic
structures. To aid in debugging and data extraction, I'd like to
persist these objects in a form that's readable, but one that also
preserves handles (ie for lambda expressions, dictionaries, lists,
etc).

Can you clarify what you might mean by "debugging and data extraction"?

The reason I ask is that if you're primarily concerned with the
ability to access the data easily outside of the program that
generated it, then have you considered just interatively loading your
picking file and performing whatever manipulations you might want?

That is, if pickle satisfies your need for the persistence of the data
structures themselves, perhaps the readability of the raw pickle file
need not be a problem if you consider just using Python to load that
file in when you need to examine it. You could always interactively
(or with small scripts if you do repetitive operations) then dump
selected portions of the data to more parseable flat text files for
use with other tools if necessary, while not losing any of the
richness of the original data structure.

I know that I've done this numerous times in the past (both with
pickle files as well as with ZODB databases) as a way to examine
stored program state in an interactive manner outside of the original
application.

-- David


The reason why I'd prefer the data stored in a readable format is so I
wouldn't have to use an interpreter to view the data (well, aside from a
text editor). Pickle doesn't even fully cut it for me since it's unable
to save lambda expressions and user defined function handles.
Jul 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Troll | last post by:
Hi, Would something like: if (-r $name) { : # do nothing } else { print "File is not readable...\n"; }
2
by: Leo | last post by:
Hi, I'm back to ASP for a short while and I was wondering how I could save the entire Application/Session-state to a file or database and how to read it back afterwards. I'd like to preserve...
0
by: Michael.McD | last post by:
Is there any consensus on the way to go when implementing object persistance to a dB? For example MHibernate v. DataObjects (x-tensive). Cheers, Michael McD
4
by: John Baro | last post by:
I need to determine which fonts are human readable. Webdings, wingdings etc.. are not. Is there any easy way to accomplish this? Cheers JB
2
by: Kiran | last post by:
Hi, This is something weird I noticed recently in ASP.Net. I have created typed dataset and I have filled the data. when a postback happens, the data of the dataset is lost. Is there a...
45
by: bigdadro | last post by:
I've created a new class using prototype.js. After I make the ajax.request all references to this.myClassMethodorVariable are lost. Does the ajax method blow out the object persistance? I'm fairly...
2
by: Jen | last post by:
I have a Hashtable serializing to a binary file ok but I really would like the file to be in XML format or other readable format. I DO NOT want to change all my code, I want to keep the Hashtable...
5
by: Jeroen | last post by:
Hi, I've found that C# 2 has several non-basic-programming-features turn out to be a great help in making code readable and typesafe, most notable the Generics stuff. Consequently, when I was...
1
by: Trevor17 | last post by:
Hello All, I am currently in a Perl programming class and our assignment was: Create a filehandle with the open function that uses a pipe to list all the files in your current directory and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.