- Published on
TIL: Python's debug f-string `{var =}` is whitespace-sensitive
The debugging feature in Python's f-strings, like {my_variable =}
, is sensitive to whitespace. The spaces around the variable name matter.
a = 10
b = 20
print(f'{a=}') # prints "a=10"
print(f'{b =}') # prints "b =20"
print(f'{a + b = }') # prints "a + b = 30"
Source: Noticed in a PyTorch tutorial - How to use CutMix and MixUp.