473,400 Members | 2,163 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,400 software developers and data experts.

pickle format question

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.

--
Tomasz Lisowski
Jul 18 '05 #1
2 1908
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.
string.printable '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLM NOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c' for c in pickle.dumps([(None), {1j:1L}, "\x7f", 1, 1.]): ... if c not in string.printable: raise ValueError, ord(c)
...


Jeff

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

iD8DBQFBcVmxJd01MZaTXX0RAgONAKCIrog9C3i8e9YCvMEYVm qaDg6qmgCgkEji
Nd7Lkv0w2uYRfc42yXrXotM=
=fXkp
-----END PGP SIGNATURE-----

Jul 18 '05 #2
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

Jul 18 '05 #3

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

Similar topics

1
by: A.B., Khalid | last post by:
I wonder if someone can explain what is wrong here. I am pickling a list of dictionaries (see code attached) and unpickling it back using the HIGHEST_PROTOCOL of pickle and cPickle. I am getting an...
14
by: simonwittber | last post by:
I've written a simple module which serializes these python types: IntType, TupleType, StringType, FloatType, LongType, ListType, DictType It available for perusal here: ...
0
by: Mike P. | last post by:
Hi all, I'm working on a simulation (can be considered a game) in Python where I want to be able to dump the simulation state to a file and be able to load it up later. I have used the standard...
8
by: Gabriel Genellina | last post by:
Hello I want to convert from pickle format to python source code. That is, given an existing pickle, I want to produce a textual representation which, when evaluated, yields the original object...
2
by: DurumDara | last post by:
Hi ! I want to create a database from datas. I want to store my datas in lists/dicts/normal variables. I thinking about that I can use the pickle to serialize/load my datas from the file. ...
10
by: crystalattice | last post by:
I'm creating an RPG for experience and practice. I've finished a character creation module and I'm trying to figure out how to get the file I/O to work. I've read through the python newsgroup...
9
by: tonyr1988 | last post by:
I'm a complete python n00b writing my first program (or attempting to, anyway). I'm trying to make the transition from Java, so if you could help me, it would be greatly appreciated. Here's the...
3
by: Jeffrey Barish | last post by:
I have a class derived from string that is used in a pickle. In the new version of my program, I moved the module containing the definition of the class. Now the unpickle fails because it doesn't...
3
by: fizilla | last post by:
Hello all! I have the following weird problem and since I am new to Python I somehow cannot figure out an elegant solution. The problem reduces to the following question: How to pickle a...
0
by: Gabriel Genellina | last post by:
En Thu, 17 Jul 2008 09:40:29 -0300, <DWebre@dotd.la.govescribi�: The example doesn't have any readline(). Make sure you open the file in binary format ('wb' or 'rb'). If you have a list of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.