You `import q`, then you can slap `q/` or `q|` in front of an expression to log the value (q/ for high precedence, q| for low precedence). These days, `f"{x=}"` is probably preferred, but I still wind up using q occasionally because of its simplicity.
Just last week I was thinking that it would be great if Python had a way to print both the name and value of a variable without having to repeat the variable name. I checked the formatting mini-language spec and when I didn't see it there I assumed it didn't have it. I'm glad to know now that it does have that feature!
There are several versions of the "the formatting mini-language" and the documentation that Google return first is for an old one which didn't have this feature :-(
Please read the comment below in the gentlest, friendliest tone possible, because my goal is to considerately inform and persuade you, dear writer :)
HTML links make it 10-100x more likely other readers will learn about the thing being mentioned (and thus help increase awareness and adoption of good tools and resources).
You `import q`, then you can slap `q/` or `q|` in front of an expression to log the value (q/ for high precedence, q| for low precedence). These days, `f"{x=}"` is probably preferred, but I still wind up using q occasionally because of its simplicity.