Python script output in file

Chris Angelico rosuav at gmail.com
Wed Mar 18 18:42:39 EDT 2015


On Thu, Mar 19, 2015 at 7:22 AM, Albert-Jan Roskam
<fomcl at yahoo.com.dmarc.invalid> wrote:
> On Wed, Mar 18, 2015 7:06 PM CET Rustom Mody wrote:
>
>>On Wednesday, March 18, 2015 at 8:12:12 PM UTC+5:30, Robert Clove wrote:
>>> ./my_eth_script.pl eth0 M > a.txt
>>>
>>> How can i run this command with subprocess.popen
>>
>>Something like this I guess?
>>
>>>> proc = Popen("cat", shell=True, stdout=open(inname, "w"), stdin=open(outname,"r"))
>
>
> How will the file object associated with in name be closed? (When is close() method called?

Once the interpreter notices that it's no longer referenced anywhere.

ChrisA



More information about the Python-list mailing list