0

I am using a python script(x.py) that required to be run using terminal, but I have a large list that need to be iterate so I did a script that can call the x.py but I could not save the output due to sys.stdout.isatty(), how can I make python script think it runs using atty device?

martineau
  • 119,623
  • 25
  • 170
  • 301
Samah
  • 15
  • 4
  • what do you exactly mean by `think it runs using terminal` ? or you could check [here](https://stackoverflow.com/questions/858623/how-to-recognize-whether-a-script-is-running-on-a-tty) – Onyambu Sep 13 '19 at 17:05
  • @Onyambu I want to run it using python IDE not the terminal and I do not have control over the original script – Samah Sep 13 '19 at 17:26

2 Answers2

0

You can monkey patch isatty to lambda x: True

another hack is at

Can you fool isatty AND log stdout and stderr separately?

Serge
  • 3,387
  • 3
  • 16
  • 34
0

I've used 'unbuffer' which is part of the 'expect' package. Search for unbuffer in this page: https://wiki.archlinux.org/index.php/Color_output_in_console

Mike McCabe
  • 1,015
  • 9
  • 9