title: Maketrans in Python 2.6
body: <p>I have got this nice little method to remove control characters from a string. Unfortunatelly, it does not work in Python 2.6 (only in Python 3.1). It states:</p>
  
  <blockquote>
  <pre><code>mpa = str.maketrans(dict.fromkeys(control_chars))
  </code></pre>
    
    <p>AttributeError: type object 'str' has no attribute 'maketrans'</p>
  </blockquote>
  
  <pre><code>def removeControlCharacters(line):
     control_chars = (chr(i) for i in range(32))
     mpa = str.maketrans(dict.fromkeys(control_chars))
     return line.translate(mpa)
  </code></pre>
  
  <p>How can it be rewritten?</p>