Discover more from Daily Dose of Data Science
7 Elegant Usages of Underscore in Python
Must-know for Python programmers.
Underscore offers many functionalities in Python.
The above animation highlights
7 of the must-know usages among Python programmers.
Retrieve the last computed value
Placeholder for loop variable
Additionally, you can also use underscore while naming objects, etc:
Single leading underscore to indicate variables for internal use
Single trailing underscore to avoid conflict with keywords
Double leading underscores to invoke name mangling
Double leading and trailing underscores to write magic methods
👉 Over to you: What other usages have I missed?
Thanks for reading Daily Dose of Data Science! Subscribe for free to learn something new and insightful about Python and Data Science every day. Also, get a Free Data Science PDF (350+ pages) with 250+ tips.
👉 Tell the world what makes this newsletter special for you by leaving a review here :)
👉 If you liked this post, don’t forget to leave a like ❤️. It helps more people discover this newsletter on Substack and tells me that you appreciate reading these daily insights. The button is located towards the bottom of this email.
👉 If you love reading this newsletter, feel free to share it with friends!
👉 Sponsor the Daily Dose of Data Science Newsletter. More info here: Sponsorship details.
Find the code for my tips here: GitHub.