DEV Community

qing
qing

Posted on • Edited on

3.8+ Proven Debug Trick

TIL: f-strings support = for quick debugging in Python 3.8+

When debugging Python code, it's often useful to quickly inspect the values of variables. In Python 3.8 and later, f-strings have a convenient feature that makes this process even easier. You can use the = symbol within an f-string to print both the name and value of a variable.

Before:

x = 5
print(f"x: {x}")
Enter fullscreen mode Exit fullscreen mode

This will output: x: 5

After:

x = 5
print(f"{x=}")
Enter fullscreen mode Exit fullscreen mode

This will output: x=5

Notice the difference? By adding the `


Follow me on Dev.to for daily Python tips and quick guides!


🛠️ Recommended Tool

If you found this useful, check out Content Creator Ultimate Bundle (Save 33%) — $29.99 and designed for developers like you.

Get instant access to our best-selling AI Dev Boost, HTML Landing Page Templates, AI Prompts for Developers, and Python Automation Scripts Pack, perfect for content creators and marketers looking to elevate their game. This bundle is a must-have for anyone looking to create stunning content, build high-converting landing pages, and drive real results. With these tools, you'll be able to create engaging content, build beautiful landing pages, and boost your online presence.


喜欢这篇文章?关注获取更多Python自动化内容!

Top comments (0)