0

My code was working perfectly fine until last week. I am using Python3.5 and Flask '1.0.2'. Flask complained about two lines: response = requests.get(f'http://{node}/get_chain') and response = {'message': f'This transaction will be added to Block {index}'} The error messages are as the following:

response = requests.get(f'http://{node}/get_chain')
                                                 ^
SyntaxError: invalid syntax

and response = {'message': f'This transaction will be added to Block {index}'} ^ SyntaxError: invalid syntax

I attached more context below as a reference. Does anybody have a clue of what's happening? Thanks a lot!

Angel Chen
  • 67
  • 1
  • 2
  • 10

1 Answers1

0

Python 3.5 does not support string interpolation.

So, this expression:

f'http://{node}/get_chain'

Won't run. It's a syntax error.

Try changing it to something like:

'http://{}/get_chain'.format(node)

And:

response = {'message': f'This transaction will be added to Block {index}'}

Need to be changed to:

response = {'message': 'This transaction will be added to Block {}'.format(index)}

You could also try upgrading to Python 3.6 or greater.

Pablo Santa Cruz
  • 176,835
  • 32
  • 241
  • 292