Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #44912

Re: Making safe file names

References <51895D03.4000300@gmail.com>
Date 2013-05-07 15:29 -0700
Subject Re: Making safe file names
From Dan Stromberg <drsalists@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.1424.1367965782.3114.python-list@python.org> (permalink)

Show all headers | View raw


On 5/7/13, Andrew Berg <bahamutzero8825@gmail.com> wrote:
> Currently, I keep Last.fm artist data caches to avoid unnecessary API calls
> and have been naming the files using the artist name. However,
> artist names can have characters that are not allowed in file names for most
> file systems (e.g., C/A/T has forward slashes). Are there any
> recommended strategies for naming such files while avoiding conflicts (I
> wouldn't want to run into problems for an artist named C-A-T or
> CAT, for example)? I'd like to make the files easily identifiable, and there
> really are no limits on what characters can be in an artist name.

You might consider:
http://stromberg.dnsalias.org/svn/backshift/trunk/escape_mod.py
http://stromberg.dnsalias.org/svn/backshift/trunk/test-escape_mod

It doubles the length of the string, but it produces safe, easily
readable escaped strings - which tends to make debugging easier.

It requires a couple of other modules (easily obtained from the same
SVN repo) though.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Making safe file names Dan Stromberg <drsalists@gmail.com> - 2013-05-07 15:29 -0700

csiph-web