here document

N

Nader Emami

L.S.,

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!

with regards,
Nader
 
H

harold fellermann

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.
"""
 
C

Craig Ringer

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).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,265
Latest member
TodLarocca

Latest Threads

Top