10 Coolest Python Features — Part II

Hidden Python features that you may not know

Photo by Chris Ried on Unsplash

6. Dictionary Comprehension

We all know about one of the best features of Python, List Comprehension. Please do check out this article, where I solved famous Leetcode problems using List Comprehension.

Dictionary comprehension

7. F-string

Python offers a simple and attractive string formatting syntax called F-String. We can easily format and print a string with dynamic values using F-string.

F-String

8. Decorators

Decorators are used for modifying the behavior of a function or class without changing its code. It can be considered as a wrapper function on top of another function or class. It is inspired by the Decorator Design Pattern.

Python Decorator

9. Zfill

The zfill method can be used pad 0’s to the left of a string to make a string of a specific length.

zfill

10. Any and All

Python offers two beautiful methods any and all which can be used to find if any or all the conditions are true respectively. Simply put, any behaves like a series of OR conditions and all behaves like a series of AND conditions.

any and all

Thank you 🤘

To know more about me, visit ganeshkumarm.me

SDE II at Amazon. ✍️ Blog Writer 🔸 👨‍💻 Full Stack Engineer