Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
stdout
#1
is there a way, that works in both Python2 and Python3, to set stdout to always automatically flush at the end of every print command or function, at least in the cases which output a newline (in more cases is ok)? in many scripts i do stdout.flush() after each print and would like to have an easier way but i don't want to have to fake it with os.write(). i do know Python3 supports flush=True in the print function, but i still want these scripts to work on Python2. the reason is to be sure output order remains consistent around various other things the script might be doing.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [subprocess] Why stdout sent to stderr? Winfried 3 419 Jan-26-2024, 07:26 PM
Last Post: snippsat
  Performance options for sys.stdout.writelines dgrunwal 11 2,995 Aug-23-2022, 10:32 PM
Last Post: Pedroski55
  changing stdout and stderr Skaperen 4 2,645 Dec-02-2020, 08:58 PM
Last Post: Skaperen
  Get stdout of a running process yok0 0 2,975 Aug-20-2020, 10:12 AM
Last Post: yok0
  will with sys.stdout as f: close sys.stdout? Skaperen 9 4,495 Nov-03-2019, 07:57 AM
Last Post: Gribouillis
  Add stdout to text file maxtimbo 3 3,099 Feb-05-2019, 12:53 AM
Last Post: maxtimbo
  stdout buffering Skaperen 5 4,656 Jun-12-2018, 06:14 AM
Last Post: Skaperen
  Subprocess - get only first few lines of stdout j.crater 3 17,018 May-30-2017, 08:12 PM
Last Post: snippsat
  Write stdout to file mcmxl22 3 4,948 Jan-01-2017, 05:03 PM
Last Post: mcmxl22
  paramiko read stdout j.crater 2 28,096 Dec-08-2016, 09:16 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020