[Tutor] pickle.dump yielding awkward output
Steven D'Aprano
steve at pearwood.info
Mon Feb 4 15:21:29 CET 2013
On 04/02/13 22:12, Spyros Charonis wrote:
> Thank you Alan, Steven,
>
> I don't care about the characters from the pickle operation per se, I just
> want the list to be stored in its native format.
That's an in-memory binary format. There is no way to get access to that from
pure Python code. You may be able to do it using the ctypes module, which is
an interface to the underlying C implementation. But keep in mind that this
is only in the CPython implementation, and will not work in IronPython, PyPy
or Jython.
> What I am trying to do is basically the Unix shell equivalent of: "Unix
> command"> newfile.txt
In Unix commands, virtually everything is text. Python is not like that --
everything is a binary object.
But you can get a text representation of Python objects, e.g. a list, with:
print repr(mylist)
--
Steven
More information about the Tutor
mailing list