Python Forum
will with sys.stdout as f: close sys.stdout?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
will with sys.stdout as f: close sys.stdout?
#5
i want to do it within the with statement so that it is sure to happen (or at least be attempted). sure, i can do it after the with. i can close the file after the with, too. the justification for using with to do a close ... i want to use for doing the rename, too. so i would expect a method that returns an object with a context manager that takes care of both the close and the rename.
Tradition is peer pressure from dead people

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


Messages In This Thread
RE: will with sys.stdout as f: close sys.stdout? - by Skaperen - Nov-02-2019, 10:42 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [subprocess] Why stdout sent to stderr? Winfried 3 537 Jan-26-2024, 07:26 PM
Last Post: snippsat
  Performance options for sys.stdout.writelines dgrunwal 11 3,262 Aug-23-2022, 10:32 PM
Last Post: Pedroski55
  Controlling what get outputted to stdout when running external commands Daring_T 4 2,230 Jan-30-2022, 05:40 PM
Last Post: bowlofred
  Did subprocess.Popen() causes main routine to pause stdout? liudr 4 3,709 May-04-2021, 08:58 PM
Last Post: liudr
  changing stdout and stderr Skaperen 4 2,739 Dec-02-2020, 08:58 PM
Last Post: Skaperen
  Get stdout of a running process yok0 0 3,078 Aug-20-2020, 10:12 AM
Last Post: yok0
  Add stdout to text file maxtimbo 3 3,214 Feb-05-2019, 12:53 AM
Last Post: maxtimbo
  Guizero HX711 Load Cell and python3 stdout? Tesla 1 3,769 Jan-16-2019, 01:15 PM
Last Post: Larz60+
  stdout buffering Skaperen 5 4,803 Jun-12-2018, 06:14 AM
Last Post: Skaperen
  stdout Skaperen 0 2,680 Mar-19-2018, 01:23 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

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