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?
#3
could that work for this other thing i want do? i want to be able to open and write a file with a temporary name of my choice and when with closes it, it also gets renamed to the permanent name.
for name in names:
    t = int(time.time()*3906250)
    with tmpopen(f'{name}-(t)',name,'w') as f
        print('#!/usr/bin/env python3',file=f)
        print('# put your code here:',file=f)
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, 03:50 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  subprocess_run and stdout flux paul18fr 2 523 Jan-09-2025, 08:50 PM
Last Post: Gribouillis
  Failing to iterate over captured StdOut tester_V 4 1,505 Jul-12-2024, 03:36 PM
Last Post: deanhystad
  [subprocess] Why stdout sent to stderr? Winfried 3 2,039 Jan-26-2024, 07:26 PM
Last Post: snippsat
  Performance options for sys.stdout.writelines dgrunwal 11 6,093 Aug-23-2022, 10:32 PM
Last Post: Pedroski55
  Controlling what get outputted to stdout when running external commands Daring_T 4 3,602 Jan-30-2022, 05:40 PM
Last Post: bowlofred
  Did subprocess.Popen() causes main routine to pause stdout? liudr 4 5,242 May-04-2021, 08:58 PM
Last Post: liudr
  changing stdout and stderr Skaperen 4 3,994 Dec-02-2020, 08:58 PM
Last Post: Skaperen
  Get stdout of a running process yok0 0 4,385 Aug-20-2020, 10:12 AM
Last Post: yok0
  Add stdout to text file maxtimbo 3 4,004 Feb-05-2019, 12:53 AM
Last Post: maxtimbo
  Guizero HX711 Load Cell and python3 stdout? Tesla 1 4,285 Jan-16-2019, 01:15 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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