<p>Complements of Phil Shapiro;</p>
<p>Use ~{} instead of ${}.</p>
<p>So this example from the current docs is wrong:</p>
<pre><code>task heredoc {
  input {
    File in
  }

  command&lt;&lt;&lt;
  python &lt;&lt;CODE
    with open(&quot;${in}&quot;) as fp:
      for line in fp:
        if not line.startswith('#'):
          print(line.strip())
  CODE
  &gt;&gt;&gt;
}
</code></pre>
<p>It should be :</p>
<pre><code>task heredoc {
  input {
    File in
  }

  command&lt;&lt;&lt;
  python &lt;&lt;CODE
    with open(&quot;~{in}&quot;) as fp:
      for line in fp:
        if not line.startswith('#'):
          print(line.strip())
  CODE
  &gt;&gt;&gt;
}
</code></pre>

CC BY-SA 4.0
2021-01-07T20:42:43.473Z
2021-01-07T20:42:43.473Z
Liam McIntyre
<p>I'm updating my WDL from draft 2 (whichs works fine) to version 1. I'm stuck with a Py snippet</p>
<pre><code>task getReadGroup {

    input {
        String inputFile
    }

    command {echo input = ${inputFile}}

    # command &lt;&lt;&lt;
    # python &lt;&lt;CODE
    # print (&quot;${inputFile}&quot;.strip().split('/'))
    # CODE
    # &gt;&gt;&gt;

    output {
    Array[String] o = read_lines(stdout())
    }
}
</code></pre>
<p>This command gives the expected result:</p>
<pre><code>input = /mnt/lustre/working/genomeinfo/data/20191015_LongRead/20191015_LongRead_1/data/LXBAB201271/LXBAB201271/LXBAB201271/20190417_0612_1-A7-D7_PAD44174_42dcde1a/fast5/test/
</code></pre>
<p>But the commented out python code:</p>
<pre><code>print (&quot;${inputFile}&quot;.strip().split('/'))
</code></pre>
<p>Gives an empty list - &quot;${inputFile}&quot; is empty in the code command for some reason!</p>
<p>Any ideas? I've tried using a File instead of String to make it just like the example in the docs (below) other than that I see no diff:</p>
<pre><code>task heredoc {
  input {
    File in
  }

  command&lt;&lt;&lt;
  python &lt;&lt;CODE
    with open(&quot;${in}&quot;) as fp:
      for line in fp:
        if not line.startswith('#'):
          print(line.strip())
  CODE
  &gt;&gt;&gt;
}
</code></pre>

CC BY-SA 4.0
2021-01-07T05:31:34.270Z
print (inputFile.strip().split('/')). ??
pippo1980
CC BY-SA 4.0
2021-01-07T05:32:51.977Z
Is that a wild guess or do you know?
Liam McIntyre
CC BY-SA 4.0
2021-01-07T05:53:31.893Z
Don’t know what is WDL and how it works but it’s like the variable it’s inputFile , and $ goes with echo, but could be wrong. Can’t try by my own given I don’t know WDL
pippo1980
CC BY-SA 4.0
2021-01-07T12:13:01.757Z
Given u don't know what WDL is it would be best if you didn't make suggestions...
Liam McIntyre
CC BY-SA 4.0
2021-01-07T19:46:43.630Z
Fine https://github.com/openwdl/wdl/blob/main/versions/1.0/SPEC.md#command-section got the use of placeholders    in whatever WDL is
pippo1980
CC BY-SA 4.0
2021-01-07T19:48:19.357Z
What does print ("${inputFile}") alone gives you
pippo1980
<python><wdl>
What changed wwith Python in WDL change from draft 2 to version 1?
# What changed wwith Python in WDL change from draft 2 to version 1?

(Asked by: username_0 on 2021-01-07)

I'm updating my WDL from draft 2 (whichs works fine) to version 1. I'm stuck with a Py snippet
task getReadGroup {

    input {
        String inputFile
    }

    command {echo input = ${inputFile}}

    # command <<<
    # python <>>

    output {
    Array[String] o = read_lines(stdout())
    }
}

This command gives the expected result:
input = /mnt/lustre/working/genomeinfo/data/20191015_LongRead/20191015_LongRead_1/data/LXBAB201271/LXBAB201271/LXBAB201271/20190417_0612_1-A7-D7_PAD44174_42dcde1a/fast5/test/

But the commented out python code:
print ("${inputFile}".strip().split('/'))

Gives an empty list - "${inputFile}" is empty in the code command for some reason!
Any ideas? I've tried using a File instead of String to make it just like the example in the docs (below) other than that I see no diff:
task heredoc {
  input {
    File in
  }

  command<<<
  python <>>
}

**Tags:** python, wdl
> **Comments:**
> **username_1**: print (inputFile.strip().split('/')). ??  
> **username_0**: Is that a wild guess or do you know?  
> **username_1**: Don’t know what is WDL and how it works but it’s like the variable it’s inputFile , and $ goes with echo, but could be wrong. Can’t try by my own given I don’t know WDL  
> **username_0**: Given u don't know what WDL is it would be best if you didn't make suggestions...  
> **username_1**: Fine https://github.com/openwdl/wdl/blob/main/versions/1.0/SPEC.md#command-section got the use of placeholders    in whatever WDL is  
> **username_1**: What does print ("${inputFile}") alone gives you  

---

## 1 answers

### Answer by username_0 on 2021-01-07. Score: 2 | Accepted answer

Complements of Phil Shapiro;
Use ~{} instead of ${}.
So this example from the current docs is wrong:
task heredoc {
  input {
    File in
  }

  command<<<
  python <>>
}

It should be :
task heredoc {
  input {
    File in
  }

  command<<<
  python <>>
}


---

