Y
yichun.wei
Perl has the ability to do the following:
print <<EOF;
...reams of text goes here...
EOF
Is there a Python equivalent of the above Perl code?
This thread has previous discussion on the topic:
http://groups.google.com/group/comp...python+EOF+perl&rnum=2&hl=en#b1788afc3150d280
we know one can use:
print """var1 = %(var1)s,
var2 = %(var2)s
... extra content..
""" % vars()
However, when the code in the string was actually
qsubcmds = """
echo
cd %(cwd)s
%(cmds) %(args)
rm -f %(files)s
""" % vars()
in which %(cmd)s folks a subprocess, when this string was write to some
pipe, e.g.:
QSUB = Popen(qsubcmds, shell=True, stdin=PIPE)
print >> QSUB.stdin, qsubcmds
(or Popen.communicate(qsubcmds))
the "rm -f " was not executed in my case.
The corresponding perl script runs fine:
open(QSUB, "| $qsubcmds -") || die "kao";
print QSUB <<End;
echo
cd $cwd
$cmds $args
rm -f $files
End
close QSUB || die "kou";
How can we manage this in Python?
print <<EOF;
...reams of text goes here...
EOF
Is there a Python equivalent of the above Perl code?
This thread has previous discussion on the topic:
http://groups.google.com/group/comp...python+EOF+perl&rnum=2&hl=en#b1788afc3150d280
we know one can use:
print """var1 = %(var1)s,
var2 = %(var2)s
... extra content..
""" % vars()
However, when the code in the string was actually
qsubcmds = """
echo
cd %(cwd)s
%(cmds) %(args)
rm -f %(files)s
""" % vars()
in which %(cmd)s folks a subprocess, when this string was write to some
pipe, e.g.:
QSUB = Popen(qsubcmds, shell=True, stdin=PIPE)
print >> QSUB.stdin, qsubcmds
(or Popen.communicate(qsubcmds))
the "rm -f " was not executed in my case.
The corresponding perl script runs fine:
open(QSUB, "| $qsubcmds -") || die "kao";
print QSUB <<End;
echo
cd $cwd
$cmds $args
rm -f $files
End
close QSUB || die "kou";
How can we manage this in Python?