Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
f-string-ify
#11
what is stopping me is not knowing what to code to evaluate the pattern (read it from a file).
from foo import *
from bar import *

with open('pattern_file.txt') as f:
    for data in f:
        pattern = data.rstrip()

out_str = fy(pattern)
print(out_str)
what change to the assignment to variable "out_str" in line 8 will have it evaluate then pattern (you cannot change what the pattern contents is expected to do but you can change its value to achieve that goal). you do not get to see the string in advance. it is a valid f-string. the solution must not be specific to any variable names.
Tradition is peer pressure from dead people

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


Forum Jump:

User Panel Messages

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