title: Python: print formatted at absolute horizontal position
body: <p>The basic question is: I know how to right align, i.e. to apply a padding of 10 spaces: </p>
  
  <pre><code>'some string %10s' % 'place me 10 spaces after previous character'
  </code></pre>
  
  <p>but how to print text at an absolute horizontal position on a line? </p>
  
  <p>I am formatting help pages, i.e. a series of string pairs using the <a href="https://docs.python.org/2/library/string.html#format-specification-mini-language" rel="nofollow noreferrer">Format Specification Mini-Language</a>. As you can see below, I am using a template and .format to write lines consisting of a command and a help string. The first output line is fine, but then I split the command in multiple lines and for this reason the help string is not rendered at horizontal position 100 (as indicated in the template):</p>
  
  <pre><code>template = "{0:30} {1:100}\n"
  command_help = [
    ('myscript --help', 
     'Show the help'),
    ('myscript do_this --option1=10 \n         --option2=3 ...', 
     'Script does something. NB bad padding'),
    ('myscript do_this --option1=10 \n         --option2=3 ...', 
     '%28s' % 'Manually adding padding does not work'),
    ('myscript do_first \nmyscript do_second \nmyscript do_third', 
     'Common command sequence to do something. NB bad padding')
  ]
  for command, help in command_help:
      print(template.format(command, help))
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>myscript --help                Show the help                                                                                       
  
  myscript do_this --option1=10 
           --option2=3 ... Script does something. NB bad padding                                                               
  
  myscript do_this --option1=10 
           --option2=3 ... Manually adding padding does not work                                                                       
  
  myscript do_first 
  myscript do_second 
  myscript do_third Common command sequence to do something. NB bad padding
  </code></pre>