How to redirect the raw_input to stderr and not stdout?

Samuel

I want to redirect the stdout to a file. But This will affect the raw_input. I need to redirect the output of raw_input to stderr instead of stdout. How can I do that?

falsetru

Redirect stdout to stderr temporarily, then restore.

import sys

old_raw_input = raw_input
def raw_input(*args):
    old_stdout = sys.stdout
    try:
        sys.stdout = sys.stderr
        return old_raw_input(*args)
    finally:
        sys.stdout = old_stdout

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to redirect error output to both stdout and to stderr?

From Dev

Linux : how to redirect stdout & stderr to logger?

From Dev

How to redirect a part of stderr and stdout to /dev/null

From Dev

How to redirect stderr in a variable but keep stdout in the console

From Dev

How can I redirect stdout and stderr with variant?

From Dev

How to redirect stdout and stderr to a file and display stderr to console?

From Java

Redirect stderr and stdout in Bash

From Dev

Redirect stdout to stderr in tcsh

From Dev

Permanently redirect stderr to stdout

From Dev

How to redirect stdout to a file, and stdout+stderr to another one?

From Dev

Redirect stdout and stderr to file and stderr to stdout

From Dev

Redirect stdout and stderr to file and stderr to stdout

From Java

How to redirect and append both stdout and stderr to a file with Bash?

From Dev

How to redirect stderr and stdout to different files and also display in terminal?

From Dev

How to redirect stderr to a file and some echos (not stdout) to the same file

From Dev

On a Linux system, how would I redirect stdout to stderr?

From Dev

How do I redirect stderr to stdout and vice versa

From Dev

How to redirect stderr/stdout of a Gtk.Window() call in python?

From Dev

How to redirect STDERR to both file and console and STDOUT to file only

From Dev

How to redirect stderr to a file and some echos (not stdout) to the same file

From Dev

How to redirect stderr and stdout to different files and also display in terminal?

From Dev

How to redirect stdin and stdout and stderr at the same time in bash?

From Dev

How to redirect stderr to stdout then pipe (apt-cache)

From Dev

Redirect STDERR and STDOUT to log with nohup

From Dev

Redirect stderr to stdout in a middle of running

From Dev

Redirect stdout and/or stderr to path in variable

From Dev

bash: redirect stderr to file and stdout + stderr to screen

From Java

Redirect Windows cmd stdout and stderr to a single file

From Dev

Bash - redirect stdout and stderr to files with background process

Related Related

  1. 1

    How to redirect error output to both stdout and to stderr?

  2. 2

    Linux : how to redirect stdout & stderr to logger?

  3. 3

    How to redirect a part of stderr and stdout to /dev/null

  4. 4

    How to redirect stderr in a variable but keep stdout in the console

  5. 5

    How can I redirect stdout and stderr with variant?

  6. 6

    How to redirect stdout and stderr to a file and display stderr to console?

  7. 7

    Redirect stderr and stdout in Bash

  8. 8

    Redirect stdout to stderr in tcsh

  9. 9

    Permanently redirect stderr to stdout

  10. 10

    How to redirect stdout to a file, and stdout+stderr to another one?

  11. 11

    Redirect stdout and stderr to file and stderr to stdout

  12. 12

    Redirect stdout and stderr to file and stderr to stdout

  13. 13

    How to redirect and append both stdout and stderr to a file with Bash?

  14. 14

    How to redirect stderr and stdout to different files and also display in terminal?

  15. 15

    How to redirect stderr to a file and some echos (not stdout) to the same file

  16. 16

    On a Linux system, how would I redirect stdout to stderr?

  17. 17

    How do I redirect stderr to stdout and vice versa

  18. 18

    How to redirect stderr/stdout of a Gtk.Window() call in python?

  19. 19

    How to redirect STDERR to both file and console and STDOUT to file only

  20. 20

    How to redirect stderr to a file and some echos (not stdout) to the same file

  21. 21

    How to redirect stderr and stdout to different files and also display in terminal?

  22. 22

    How to redirect stdin and stdout and stderr at the same time in bash?

  23. 23

    How to redirect stderr to stdout then pipe (apt-cache)

  24. 24

    Redirect STDERR and STDOUT to log with nohup

  25. 25

    Redirect stderr to stdout in a middle of running

  26. 26

    Redirect stdout and/or stderr to path in variable

  27. 27

    bash: redirect stderr to file and stdout + stderr to screen

  28. 28

    Redirect Windows cmd stdout and stderr to a single file

  29. 29

    Bash - redirect stdout and stderr to files with background process

HotTag

Archive