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_run and stdout flux paul18fr 2 526 Jan-09-2025, 08:50 PM
Last Post: Gribouillis
  Failing to iterate over captured StdOut tester_V 4 1,521 Jul-12-2024, 03:36 PM
Last Post: deanhystad
  [subprocess] Why stdout sent to stderr? Winfried 3 2,051 Jan-26-2024, 07:26 PM
Last Post: snippsat
  Performance options for sys.stdout.writelines dgrunwal 11 6,104 Aug-23-2022, 10:32 PM
Last Post: Pedroski55
  changing stdout and stderr Skaperen 4 4,004 Dec-02-2020, 08:58 PM
Last Post: Skaperen
  Get stdout of a running process yok0 0 4,391 Aug-20-2020, 10:12 AM
Last Post: yok0
  will with sys.stdout as f: close sys.stdout? Skaperen 9 7,037 Nov-03-2019, 07:57 AM
Last Post: Gribouillis
  Add stdout to text file maxtimbo 3 4,012 Feb-05-2019, 12:53 AM
Last Post: maxtimbo
  stdout buffering Skaperen 5 6,254 Jun-12-2018, 06:14 AM
Last Post: Skaperen
  Subprocess - get only first few lines of stdout j.crater 3 22,802 May-30-2017, 08:12 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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