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


Groups > comp.lang.python > #44907

Re: Making safe file names

From Terry Jan Reedy <tjreedy@udel.edu>
Subject Re: Making safe file names
Date 2013-05-07 18:01 -0400
References <51895D03.4000300@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.1420.1367964109.3114.python-list@python.org> (permalink)

Show all headers | View raw


On 5/7/2013 3:58 PM, Andrew Berg 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.

Sounds like you want something like the html escape or urlencode 
functions, which serve the same purpose of encoding special chars. 
Rather than invent a new tranformation, you could use the same scheme 
used for html entities. (Sorry, I forget the details.) It is possible 
that one of the functions would work for you as is, or with little 
modification.

Terry


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


Thread

Re: Making safe file names Terry Jan Reedy <tjreedy@udel.edu> - 2013-05-07 18:01 -0400

csiph-web