The most pythonic way I can think of is using f-strings (3.8 required) pi = 3.14159 print(f”{pi=}”) --------- pi=3.14159 --------- This does however require you to know the name, so the library is probably directly reading locals() and or globals()… If you want to know how the F-String knows the variable name, you’d probably have to dig in the c source code for python.
Nice short, very straightforward, and useful video.
Glad you liked it
So it's f strings but not built into the language? Why not use print(f"{user_weight=}")
Nice thx. Useful
😀 your welcome!
what magic did ic use to know the variable/function name?
The most pythonic way I can think of is using f-strings (3.8 required)
pi = 3.14159
print(f”{pi=}”)
---------
pi=3.14159
---------
This does however require you to know the name, so the library is probably directly reading locals() and or globals()…
If you want to know how the F-String knows the variable name, you’d probably have to dig in the c source code for python.
@@raumi_ Thanks for your explanation
Nice thanks
so cool
Yoooooooo bro