I have a Python 3.11 script that fails with a syntax error:
values, value = [], "foo" values.append(f"'{string(value).replace('"', '""')}'") I don't understand why, please explain.
values.append(f"'{string(value).replace('"', '""')}'") File "<stdin>", line 1 values.append(f"'{string(value).replace('"', '""')}'") ^ SyntaxError: unterminated string literal (detected at line 2)
values.append(str(value).replace('"', '""')), as it appears the f-string is superfluous. Then again, the question in its original (current) state is not reproducible.valueis irrelevant.stringshould bestr):values.append(f"""'{str(value).replace('"', '""')}'""")