Python Forum
reading an f-string from a file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
reading an f-string from a file
#1
i am reading a string from a file. how can i have it be interpreted as an f-string?


   num = 123456789
   with open('thefile') as openf: # this file has: number is {num}
       bar = do_f_string(openf.readline().rstrip())
   foo = f'number is {num}'
   print(foo)
   print(bar)
the above code should output the same line twice when do_f_string() is the function doing what i seek.
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
reading an f-string from a file - by Skaperen - Nov-01-2019, 10:29 PM
RE: reading an f-string from a file - by Skaperen - Nov-02-2019, 10:57 PM
RE: reading an f-string from a file - by Skaperen - Nov-03-2019, 01:59 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  reading a file like the unix tail -f command does Skaperen 2 301 Mar-31-2024, 12:09 AM
Last Post: Skaperen
  reading and writing a image stored in a file Skaperen 4 2,242 Feb-12-2022, 04:03 AM
Last Post: Skaperen
  reading remote active log file? korenron 3 2,886 Jun-24-2021, 09:07 AM
Last Post: korenron

Forum Jump:

User Panel Messages

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