Saving (unusual) linux filenames

Jeremy Sanders jeremy at jeremysanders.net
Tue Aug 31 12:58:55 EDT 2010


AmFreak at web.de wrote:

> i have a script that reads and writes linux paths in a file. I save the
> path (as unicode) with 2 other variables. I save them seperated by "," and
> the "packets" by newlines. So my file looks like this:
> path1, var1A, var1B
> path2, var2A, var2B
> path3, var3A, var3B

If you're generating the file and it is safe to do so (you're not getting 
the data from the internet), you could use repr((path1, v1, v2)) to save the 
line to the file and eval to interpret back the tuple.

Alternatively you could use // as a separator, making sure that you replace 
multiple slashes in the path which a single slash (which are equivalent).

Jeremy





More information about the Python-list mailing list