output to console and to multiple files

nathan.shair at gmail.com nathan.shair at gmail.com
Fri Feb 16 10:36:29 EST 2007


On Feb 15, 5:48 pm, "Gabriel Genellina" <gagsl... at yahoo.com.ar> wrote:
> En Thu, 15 Feb 2007 19:35:10 -0300, Matimus <mccre... 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

I've tried the subprocess method before without any luck.


Thanks for all your suggestions. I guess it's time to rethink what I
want to do.




More information about the Python-list mailing list