Serialization, save type information in file and restore them

Timothy Wu 2huggie at gmail.com
Fri Jun 18 07:24:01 EDT 2010


Hi,

I created a class that's able to manipulate tabulated data. I want to be
able to dump the bulk of the data and other attributes as a tab-delimited
text. I have trouble saving/restoring type information in the file. For
example, some attributes are int, others may be float, etc. So I want to
store the data type as well as the data value themselves in a file. And I
don't think I want to use Pickle because I want it to be readily opened in
vi and be readable as a tab-delimited file and be able to import into Excel
as well.

What's the best way to achieve this? I was able to write string like
"attribute = int(value)" into a file. But how do I get the value back? I
want the "int(value)" string to be loaded into the program and be executable
so I can actually create the instance variable in the class.

Any help appreciated, thanks.

Timothy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100618/5b5f7044/attachment.html>


More information about the Python-list mailing list