Filename for stdout

James Mills prologic at shortcircuit.net.au
Thu Oct 21 05:07:54 CEST 2010


On Thu, Oct 21, 2010 at 6:17 AM, Richard Gibbs
<richard.gibbs at smooth-stone.com> wrote:
> If my python script is called with stdout (or stdin or stderr) redirected to
> a file, how can I find the filename under Linux?  Under Windows?

I don't believe there is a way to do this.

The shell normally takes care of pipes.

When you do:

$ ./foo > /tmp/foobar

You're telling your shell to write the stdout output of foo to the
file /tmp/foobar

sys.stdout won't actually tell you anything useful.
It's normally just a file descriptor.

cheers
James

-- 
-- James Mills
--
-- "Problems are solved by method"



More information about the Python-list mailing list