It’s 2024, the year of the linux desktop, and the best™ way to debug computer programs is still the good ol’ print statement.

Since Python 3.6 it is possible to use f-strings.

One of my favorite ways to use them for debugging is with the equal sign (=):

To display both the expression text and its value after evaluation, (useful in debugging), an equal sign '=' may be added after the expression.

Here is one example:

def is_full_word_match(token, words):
    print(f'  is_full_word_match: {token=} {words=}')
    return token in words

If you call it like so:

is_full_word_match("hello", "hello world")

Then it will print the following:

  is_full_word_match: token='hello' words='hello world'

This is a more ergonomic (and quicker) way to write than the classic:

print('  is_full_word_match: token=' + token + ' words=' + words)

Or even:

print('  is_full_word_match: token={} words={}'.format(token, words))