On Tue, 2005-01-11 at 18:46, harold fellermann wrote:
On 11.01.2005, at 11:34, Nader Emami wrote: Would somebody help me how i can write the 'here document' in
Python script please? I have a csh script in which a program
is invoked with some argument in the form of here document:
/bin/exe.x << End_Here
CategorY = GRIB
etc.
End_Here
I translate this script to Python and i don't know how can I
do this!
f = open("/bin/exe.x","w")
print >>f , """CategoryY = GRIB
etc.
"""
You mean "os.popen" not "open" I assume? The former opens a pipe to a
command, the latter overwrites the file.
I'd use:
os.popen("/bin/exe.x", "w").write("""\
CategorY = GRIB
etc.
""")
myself, but that's just taste (well, and performance I suspect).
--
Craig Ringer