Name of the file associated with sys.std*
Matthew Woodcraft
mattheww at chiark.greenend.org.uk
Wed Aug 30 18:45:04 EDT 2006
Henryk Modzelewski <henryk at eos.ubc.ca> wrote:
>It might be a trivial question, but I seem to be lost.
>
>Is there a way to get names of the files associated with stdin/out/
>err if those are redirected to the files at the shell command-line?
I doubt there is a portable way. On most linux-based systems,
os.readlink("/proc/self/fd/1")
and
os.readlink("/proc/self/fd/2")
will work.
-M-
More information about the Python-list
mailing list