D
destroooooy
Hi folks,
I'm finding some (what I consider) curious behavior with the string
methods and the forward slash character. I'm writing a program to
rename mp3 files based on their id3 tags, and I want to protect
against goofy characters in the in tags. So I do the following:
unsafe_chars = "/#()[]!@$%^&*{}\'\"`?<>| \t\n"
alt_chars = "_________________________"
s_artist.translate(maketranstable(unsafe_chars, alt_chars))
which successfully replaces everything except for forward slashes (at
least in the files I've tested so far). If I use the "replace()"
method, it also does not work. Escaping the forward slash changes
nothing. "find()" however, works, and thus I've resorted to:
if "/" in s_artist:
(s_l, slash, s_r) = s_artist.partition("/")
s_artist = "_".join([s_l, s_r])
which is rather uncool. It works but I'd just like to know what the
deal is. TIA.
I'm finding some (what I consider) curious behavior with the string
methods and the forward slash character. I'm writing a program to
rename mp3 files based on their id3 tags, and I want to protect
against goofy characters in the in tags. So I do the following:
unsafe_chars = "/#()[]!@$%^&*{}\'\"`?<>| \t\n"
alt_chars = "_________________________"
s_artist.translate(maketranstable(unsafe_chars, alt_chars))
which successfully replaces everything except for forward slashes (at
least in the files I've tested so far). If I use the "replace()"
method, it also does not work. Escaping the forward slash changes
nothing. "find()" however, works, and thus I've resorted to:
if "/" in s_artist:
(s_l, slash, s_r) = s_artist.partition("/")
s_artist = "_".join([s_l, s_r])
which is rather uncool. It works but I'd just like to know what the
deal is. TIA.