unpickle to python list

Andrew Bennetts andrew-pythonlist at puzzling.org
Mon Feb 3 07:33:04 EST 2003


On Mon, Feb 03, 2003 at 01:16:33PM +0100, Thomas Guettler wrote:
> Hi!
> 
> I have a pickle which contains a flat list:
> 
> mylist=[
>  "abc",
>  "def",
>  "ghi", ...]
> 
> Is it possible to pickle this list to python syntax?
> 
> I would like to get a foo.py file which contains
> this list in python syntax.
> 
> This would make it easy to edit the list with an text
> editor.

For lists containing things like strings, you could simply write the result
of "repr(mylist)" to a file.

On the other hand, if all your list contains is simple strings, writing the
strings to a file, one per line, is even easier...

So really, the answer depends on what's in the list.

-Andrew.






More information about the Python-list mailing list