Should I close after popen??
Sean 'Shaleh' Perry
shaleh at valinux.com
Thu Mar 15 17:27:04 EST 2001
On 15-Mar-2001 Andrew Markebo wrote:
> I am hacking away a small background program, using popen to call
> commands, should I close the file in some way when done or it is taken
> care of automagically??
>
> I do something like this once every 10 mins..
>
> fd1=os.popen("command")
> fd2=os.popen("command")
> os.wait(fd1)
> os.wait(fd2)
> values=fd1.read()+fd2.read()
>
> And.. anything to worry about, nesting popen/wait like this??
> (Linux/Solaris)
>
if that is in a loop, it should be fine:
while 1:
f = open(file) # every time the loop repeats, f gets closed and opened
# again
# do things to f
More information about the Python-list
mailing list