pickle format question

T

Tomasz Lisowski

The documentation says, that the output from pickle.dumps() consists of
"printable ASCII" characters. Does it mean the range from ASCII 32 to
127? Or the expected character range is different?

It would be best, if the character 127 was also excluded :)

I need this information for creating the text file containing the
pickled Python data (strings, numbers, tuples, lists, nothing else) in
the encoded (enciphered) form.
 
J

Josiah Carlson

The documentation says, that the output from pickle.dumps() consists of
"printable ASCII" characters. Does it mean the range from ASCII 32 to
127? Or the expected character range is different?

It would be best, if the character 127 was also excluded :)

I need this information for creating the text file containing the
pickled Python data (strings, numbers, tuples, lists, nothing else) in
the encoded (enciphered) form.

Test it out on your data. Encoding those objects using:
pickle.dumps(obj, 0)
I was not able to find any instances of character 127, but that may be
due to my data.

- Josiah
 
J

Jeff Epler

Pickle output at least includes "\n" in addition to ASCII 32..126.

I believe that '\x7f' (ascii 127) will not be present in the output:
Strings are dumped in repr-like form, so ASCII 127 will be ouput as a
\x-sequence. Numbers (floats, ints and longs) are also dumped in
repr-like form, and tuples and lists use just a few printable ASCII
characters in 32..126.
... if c not in string.printable: raise ValueError, ord(c)
...
Jeff

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)

iD8DBQFBcVmxJd01MZaTXX0RAgONAKCIrog9C3i8e9YCvMEYVmqaDg6qmgCgkEji
Nd7Lkv0w2uYRfc42yXrXotM=
=fXkp
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top