Salesforce, Python, SQL, & other ways to put your data where you need it

Need event music? 🎸

Live and recorded jazz, pop, and meditative music for your virtual conference / Zoom wedding / yoga class / private party with quality sound and a smooth technical experience

A dumb Python mistake

25 Aug 2021 🔖 python
💬 EN

Read on for how I went to bed angry over a mysterious API error that turned out to be a Python version error.

I kept receiving this error every time I ran my Python script from a remote server:

File "/folder/", line 60:
  f'API operation failed because something happened wrong on the underlying server of the API.  HTTP response status code {response.status_code}.')
SyntaxError: invalid Syntax

I was convinced that since it worked on my machine, the API server was cutting off calls from my remote Python environment’s IP address or something.

After all, how else would the execution engine have reached the if response.status_code == 500: branch of my source code that I was looking at?

Facepalm in the morning … I realized that it wasn’t interpolating {response.status_code} into the output. I’d thought that was strange but didn’t think it was important until I looked at it with fresh eyes.

I was running Python 3.9 on my local machine, so “f-strings” worked on my computer, but an older version of Python on the remote server, so they didn’t.

I wasn’t seeing a line of code from a running program – I was seeing a line of code that the execution engine couldn’t even compile. It never got to running my program.

--- ---