[PYTHON] Don't get angry with Git Bash's "stdout is not a tty"

Introduction

I've been worried about it for about a year, but I've just found a solution, so I'll report it.

phenomenon

When I use redirects and pipes in GitBash, I get this message and it doesn't work.

$ python bin/regression.py > out.txt
stdout is not a tty

Every day I think about workarounds every time this comes out.

Workaround (example)

--I can't use less, stare at the flowing message, and press Ctrl-C to quit where I want to see it. Then use the scroll bar to adjust what you want to see. --Because you cannot redirect, write the code to output to a file programmatically. Alternatively, start a DOS command prompt and execute it.

I also tried Don't get angry with Git Bash tty, but it doesn't work.

Correspondence

(A) I put my heart into it and examined it. Then I found this story (see Resources)

** Add an extension to the command **

(Self) That's it? Lie. It's not the basis.

(A) Is that okay? Then, let's try it. (Execute command)

$ python.exe bin/regression.py > out.txt

(Self) Yeah, lie, it's moving. Cant Believe It. What's going on with the pipes !!!?

(A) (Execute command)

$ python.exe bin/regression.py | less

(Self) I got out. You can go to the next page with a space. Awesome.

(Self) Grounds? It doesn't matter. You should move!

reference

https://stackoverflow.com/questions/40680812/mysql-git-bash-winpty-mysqldump-stdout-is-not-a-tty-and-stdin-is-not-a-tty/44727575#44727575

Recommended Posts

Don't get angry with Git Bash's "stdout is not a tty"
Python list is not a list
[Python] What is a with statement?
I want to get angry with my mom when my memory is tight