title: Is there a better way to mask a Credit Card number in python?
body: <p>So I have a csv file that contains full credit-card numbers.. We dont need the full number, and so I am writing a quick script to parse through the csv and replace the cc number with a masked representation. (all *'s except the last four).  I am pretty new to python and hacked this up, and it works, but in order to learn I want to know if it could be done easier.</p>
  
  <p>Assume that "str" will be a full creditcard number.  But for the sake of my example I am just using the string "CREDITCARDNUMBER".</p>
  
  <pre><code>str = "CREDITCARDNUMBER";
  strlength = len(str)
  masked = strlength - 4
  slimstr = str[masked:]
  print "*" * masked + slimstr
  </code></pre>
  
  <p>The output is exactly what I want</p>
  
  <pre><code>************MBER
  </code></pre>
  
  <p>But I am sure there is a more elegant solution. :) Thanks!</p>