title: Securely Erasing Password in Memory (Python)
body: <p>How do you store a password entered by the user in memory and erase it securely after it is no longer need?</p>
  
  <p>To elaborate, currently we have the following code:</p>
  
  <pre><code>username = raw_input('User name: ')
  password = getpass.getpass()
  mail = imaplib.IMAP4(MAIL_HOST)
  mail.login(username, password)
  </code></pre>
  
  <p>After calling the <code>login</code> method, what do we need to do to fill the area of memory that  contains password with garbled characters so that someone cannot recover the password by doing a core dump?</p>
  
  <p>There is a similar question, however it is in Java and the solution uses character arrays:
  <a href="https://stackoverflow.com/questions/646224/how-does-one-store-password-hashes-securely-in-memory-when-creating-accounts">How does one store password hashes securely in memory, when creating accounts?</a></p>
  
  <p>Can this be done in Python?</p>