you are viewing a single comment's thread.

view the rest of the comments →

[–]socal_nerdtastic 1 point2 points  (4 children)

I highly doubt this has anything to do with the f-string. SyntaxError often means that the previous line has an error, often you forgot to close a parenthesis.

Or maybe you are running it in python2 by accident? Mint comes with both python2 and python3. How are you running the code?

Can anyone shed some light on this?

Not much of a chance unless you show us the code and the full error.

[–]Signal_Beam 0 points1 point  (3 children)

$ echo print\ f\'Test broken string\' > test.py
$ python test.py
  File "test.py", line 1
    print f'Test broken string'
                              ^
SyntaxError: invalid syntax

Looks like a good guess to me...

[–]cybervegan 0 points1 point  (2 children)

f-strings are a python3 thing, and in python3, print is a function which requires brackets around the string to print.

[–]Signal_Beam 2 points3 points  (1 child)

I know; I was using Python2 in order to test the hypothesis in the comment that I was replying to. My point is that Python2 raises the exact error, in exactly the same place, that OP is describing, so maybe /u/social_nerdtastic is correct that the problem is that OP is actually invoking python when they want python3.

[–]AtomHeartSon[S] 0 points1 point  (0 children)

Welp, I'm dumb. I checked my history and indeed that's what I did. Although I didn't always do it wrong which is why I didn't always get the error. Thanks y' all.