Single vs. Double Quotes in Jupyter Notebooks

The Jupyter notebooks in the downloads for the Flask example have single quotes around the form data for the POST and PUT operations. Since !curl is executed in the underlying shell, one should not use single quotes as different shells can interpret those differently in general, and specifically in the context of curl.

I kept getting Bad Request 400 responses when I tried to execute the POST and PUT cells in my local Jupyter environment which is launched on top of Git Bash, a fairly typical bash implmentation.

While:

-d ‘{“username”:“testuser”,“password”:“securepassword”}’

works in the Coursera notebook environments, it fights with many underlying shells.

Using double quotes throughout and escaping the payload ones will reliably work in all underlying shells. So, I strongly suggest you alter the notebook cells to:

-d “{\“username\”:\“testuser\”,\“password\”:\“securepassword\”}”

to avoid confusion for students who choose to use their own environments.

On the plus side, I was able to use Chat GPT 4o to guide my analysis when things worked fine from Postman but always through errors with !curl in the provided notebook in my local Jupyter environment.

(NOTE: I had to use double backslashes in the second syntax example above to get them to render properly for people reading the post. The actual implementation only requires one backslash to escape the double quotes.)

Another option is to use the “preformatted text” tag while you are editing your reply.

2 Likes

I think the labs are meant primarily to be run on coursera jupyter environment, it is normal for almost all the courses here if run in local environments to need modifications. But I m going through this course right now, let me see again later on the nature of this suggestion! Thank you.

Agreed that different environments often require specific tweaks. I’m just suggesting this change as it will eliminate environment-specific nuances for this use case and cut down on the work for the student. The instructor frequently encourages the student to use their own LLM and their own execution environments, so this will reduce the friction for folks who choose to take him up on that suggestion (like me :upside_down_face:).

1 Like

@gent.spah, this seems worth of submitting a repo ticket to have the staff consider.

1 Like

Will do so @TMosh, I just wanted to go over this course myself first but a suggestion is always good to have.