title: Pad or truncate string based on fixed length
body: <p>Currently have code that looks something like;</p>
  
  <pre><code>print '{: &lt;5}'.format('test')
  </code></pre>
  
  <p>This will pad my string with <code>' '</code> if it is less than 5 characters. If the string is more than 5 characters, I'd need the string to be truncated. </p>
  
  <p>Without explicitly checking the length of my string before formatting it, is there a better way to pad if less than fixed length or truncate if greater than fixed length?</p>