Marshal Obj is String or Binary?

Mike mike12mike12 at hotmail.com
Fri Jan 13 15:25:10 EST 2006


Hi,

The example below shows that result of a marshaled data structure is
nothing but a string

>>> data = {2:'two', 3:'three'}
>>> import marshal
>>> bytes = marshal.dumps(data)
>>> type(bytes)
<type 'str'>
>>> bytes
'{i\x02\x00\x00\x00t\x03\x00\x00\x00twoi\x03\x00\x00\x00t\x05\x00\x00\x00three0'

Now, I need to store this data safely in my database as CLEAR TEXT, not
BLOB. It seems to me that it should work just fine since it is string
anyways. So, why does O'reilly's Python Cookbook is insisting in saving
it as a binary file and BLOB type?

Am I missing out something?

Thanks,
Mike




More information about the Python-list mailing list