Remove all the parentheses and replace all spaces by underscores?
<p>Here is what I did:</p>

<pre><code>import re
def demicrosoft (fn):

    fn = re.sub('[()]', '', fn)
    for ch in [' ']:
        fn = fn.replace(ch,"_"+ch)
    return fn
print(demicrosoft('a bad file name (really)')) 
</code></pre>

<p><br></p>

<pre><code>&gt;&gt;&gt; (executing lines 1 to 12 of "&lt;tmp 2&gt;")
a_ bad_ file_ name_ really
</code></pre>

<p>There are spaces followed with the underscores. How can I fix it? </p>