-
I have a Python data loader that ran fine on my own machine, but it failed on the Observable Framework build for what it claimed was a problem with a closing ] in an f-string. I'm not sure if this is possibly a bug on the Framework end, or on the Node.js end, or if the issue is something else, so I'm posting here instead of in Issues. The error that I got from the GitHub deploy log is:
But there's not actually a problem with that f-string, the bracket is closed properly, and the single/double quotes are properly alternated. Assigning the interpolated bit to a variable and putting that into the f-string instead worked fine when deployed, but it should have worked the first time around. Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
shouldn't the internal double-quotes be escaped? - f"obj_id == '{row2["wd_sub_id"]}'"
+ f"obj_id == '{row2[\"wd_sub_id\"]}'" |
Beta Was this translation helpful? Give feedback.
-
Python 3.12 changes f-strings to allow internal quotes of the same type as the external quotes without escaping. Python 3.11 and below will have problems with syntax. What version of Python are you using? |
Beta Was this translation helpful? Give feedback.
I'm not a Python expert, but your sample code works in 3.12 and doesn't work in 3.11. Either way, it doesn't work on Observable Cloud. You'll need to update your code to pull
row2["wd_sub_id"]
into an intermediate variable.