output to console and to multiple files
Gabriel Genellina
gagsl-py at yahoo.com.ar
Thu Feb 15 19:48:22 EST 2007
En Thu, 15 Feb 2007 19:35:10 -0300, Matimus <mccredie at gmail.com> escribió:
>> I think you should be able to use my or goodwolf's solution with the
>> subprocess module. Something like this (untested):
>>
>> [code]
>> class TeeFile(object):
>> def __init__(self,*files):
>> self.files = files
>> def write(self,txt):
>> for fp in self.files:
>> fp.write(txt)
>>
>
> I tried this at lunch and it doesn't work. Some version of this method
> may work, but Popen tries to call the 'fileno' method of the TeeFile
> object (at least it did on my setup) and it isn't there. This is just
> a preemptive warning before someone comes back to let me know my code
> doesn't work.
I don't think any Python only solution could work. The pipe options
available for subprocess are those of the underlying OS, and the OS knows
nothing about Python file objects.
--
Gabriel Genellina
More information about the Python-list
mailing list