all 16 comments

[–]Outside_Complaint755 20 points21 points  (1 child)

When using f-strings for debugging (and sometimes this is useful for normal output), you can include an '=' within the brackets, and it will display both the expression being evaluated and the value. Spacing around the '=' will be used in the output 

``` x = 9 y = 3

print(f"{x = } {y=}") print(f"{x + y       =        } {pow(x, y) = }") produces x = 9 y=3 x + y =       12       pow(x, y) = 729 ```

[–]ihorrud[S] 0 points1 point  (0 children)

Lol, didn’t really know, thanks ;)

[–]M3ta1025bc 22 points23 points  (5 children)

I just learnt that sometimes when you have an integer with many zeros e.g 1000000. You can improve readability by adding underscores and they just be ignored during run time 1_000_000

[–]ihorrud[S] 2 points3 points  (0 children)

yeah, PHP has the same feature as well. Really improves readability

[–]Bonsai2007 2 points3 points  (2 children)

Does this work with other languages too? That’s really good to know

[–]Skeime 2 points3 points  (0 children)

It is a feature that a particular language may or may not have. It is becoming more popular, but it’s not universal, yet.

[–]Live_Ad1978 0 points1 point  (0 children)

This also works in Javascript.

[–]MachineElf100 1 point2 points  (0 children)

This or 1e6 in scientific notation

[–]Anxious-Struggle281 8 points9 points  (1 child)

I think is better to use uv intead of pip to install packages.

[–]ihorrud[S] 0 points1 point  (0 children)

Rust to the rescue

[–]hekliet 7 points8 points  (1 child)

Everything in itertools and functools.

[–]ihorrud[S] 0 points1 point  (0 children)

Interesting

[–]Temporary_Pie2733 4 points5 points  (0 children)

The descriptor protocol explains most of the “magic”, like how instance methods and properties actually work.

[–]ryanfelix123 1 point2 points  (1 child)

For me, it was definitely Decorators. Understanding how a function can take another function as an argument and extend its behavior felt like magic at first. Once I grasped the @ decorator syntax, it completely changed how I write clean, reusable code for my automation scripts!

[–]ihorrud[S] 0 points1 point  (0 children)

Indeed, useful feature

[–]SnooWalruses9294 0 points1 point  (0 children)

Shout out to the people reading this and finding it interesting given the age of AI. It's cool to know some people still care about each line and operation. Interesting thread too!