Python Tip #4 (of 365):

If you're debugging with print() calls, use a self-documenting expression in an f-string.

>>> n = 256
>>> print(f"DEBUGGING {n**2=}")
DEBUGGING n**2=65536

Note the replacement field with = at the end.

Without = in the replacement field, the string would contain only the expression result:

>>> print(f"DEBUGGING {n**2}")
DEBUGGING 65536

With the =, the string contains both the replacement field expression and the expression result.

(1/2)๐Ÿงต

0

If you have a fediverse account, you can quote this note from your own instance. Search https://mastodon.social/users/treyhunner/statuses/115838094153004669 on your instance and quote it. (Note that quoting is not supported in Mastodon.)