title: How can I interpolate variables in Python heredocs?
body: <p>In Perl languages, I can interpolate in double quoted heredocs:</p>
  
  <p>Perl:</p>
  
  <pre><code>#!/bin/env perl
  use strict;
  use warnings;
  
  my $job  = 'foo';
  my $cpus = 3;
  
  my $heredoc = &lt;&lt;"END";
  #SBATCH job $job
  #SBATCH cpus-per-task $cpus
  END
  
  print $heredoc;
  </code></pre>
  
  <p>Raku (F.K.A. Perl 6):</p>
  
  <pre><code>#!/bin/env perl6
  
  my $job  = 'foo';
  my $cpus = 3;
  
  my $heredoc = qq:to/END/;
      #SBATCH job $job
      #SBATCH cpus-per-task $cpus
      END
  
  print $heredoc;
  </code></pre>
  
  <p>How do I do something similar in Python? In searching "heredoc string interpolation Python", I did come across information on Python f-strings, which facilitate string interpolation (for Python 3.6 and later).</p>
  
  <p>Python 3.6+ with f-strings:</p>
  
  <pre><code>#!/bin/env python3
  
  job  = 'foo'
  cpus = 3
  print(f"#SBATCH job {job}")
  print(f"#SBATCH cpus-per-task {cpus}")
  </code></pre>
  
  <p>All three of the above produce the exact same output:</p>
  
  <blockquote>
  <pre><code>#SBATCH job cutadapt
  #SBATCH cpus-per-task 3
  </code></pre>
  </blockquote>
  
  <p>That's all nice and everything, but I'm still really interested in interpolation in <strong><em>heredocs</em></strong> using Python.</p>