Skip to content

Python data loader f-string problem? #2009

Answered by mythmon
dkrasne asked this question in Q&A
Discussion options

You must be logged in to vote

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.

❯ nix-shell -p python312 --run python
Python 3.12.11 (main, Jun  3 2025, 15:41:47) [GCC 14.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> row2 = {"wd_sub_id": 1}
>>> f"obj_id == '{row2["wd_sub_id"]}'"
"obj_id == '1'"

❯ nix-shell -p python311 --run python
Python 3.11.13 (main, Jun  3 2025, 18:38:25) [GCC 14.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> row2 = {"wd_sub_id": 1}
>>> f"obj…

Replies: 2 comments 8 replies

Comment options

You must be logged in to vote
3 replies
@dkrasne
Comment options

@Fil
Comment options

Fil Jul 16, 2025
Collaborator

@dkrasne
Comment options

Comment options

You must be logged in to vote
5 replies
@dkrasne
Comment options

@mythmon
Comment options

mythmon Jul 16, 2025
Collaborator

@dkrasne
Comment options

@mythmon
Comment options

mythmon Jul 16, 2025
Collaborator

Answer selected by dkrasne
@dkrasne
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants