You Have Been Writing These 15 Python Functions From Scratch. They Already Exist in stdlib
📰 Medium · Python
Discover 15 Python functions you've been writing from scratch that already exist in the standard library, and learn how to use them to improve your coding efficiency
Action Steps
- Explore the Python standard library to find existing functions for common tasks
- Use the `heapq` module to find the top-N items in a list
- Utilize the `itertools` module to flatten nested lists
- Apply the `groupby` function from the `itertools` module to group a list of dictionaries by a key
- Replace custom functions with existing standard library functions to improve code readability and maintainability
Who Needs to Know This
Software engineers and developers can benefit from this article by learning about existing Python functions that can simplify their coding tasks and improve productivity
Key Insight
💡 Many common programming tasks have existing solutions in the Python standard library, which can simplify coding and improve productivity
Share This
🚀 Boost your Python coding efficiency by using existing standard library functions! 💻
Key Takeaways
Discover 15 Python functions you've been writing from scratch that already exist in the standard library, and learn how to use them to improve your coding efficiency
Full Article
Title: You Have Been Writing These 15 Python Functions From Scratch. They Already Exist in stdlib
URL Source: https://medium.com/@swarnenduiitb2020/you-have-been-writing-these-15-python-functions-from-scratch-they-already-exist-in-stdlib-99135bc126f2?source=rss------python-5
Published Time: 2026-04-23T19:31:01Z
Markdown Content:
# You Have Been Writing These 15 Python Functions From Scratch. They Already Exist in stdlib | by DrSwarnenduAI | Apr, 2026 | Medium
[Sitemap](https://medium.com/sitemap/sitemap.xml)
[Open in app](https://play.google.com/store/apps/details?id=com.medium.reader&referrer=utm_source%3DmobileNavBar&source=post_page---top_nav_layout_nav-----------------------------------------)
Sign up
[Sign in](https://medium.com/m/signin?operation=login&redirect=https%3A%2F%2Fmedium.com%2F%40swarnenduiitb2020%2Fyou-have-been-writing-these-15-python-functions-from-scratch-they-already-exist-in-stdlib-99135bc126f2&source=post_page---top_nav_layout_nav-----------------------global_nav------------------)
[](https://medium.com/?source=post_page---top_nav_layout_nav-----------------------------------------)
Get app
[Write](https://medium.com/m/signin?operation=register&redirect=https%3A%2F%2Fmedium.com%2Fnew-story&source=---top_nav_layout_nav-----------------------new_post_topnav------------------)
[Search](https://medium.com/search?source=post_page---top_nav_layout_nav-----------------------------------------)
Sign up
[Sign in](https://medium.com/m/signin?operation=login&redirect=https%3A%2F%2Fmedium.com%2F%40swarnenduiitb2020%2Fyou-have-been-writing-these-15-python-functions-from-scratch-they-already-exist-in-stdlib-99135bc126f2&source=post_page---top_nav_layout_nav-----------------------global_nav------------------)

[Mastodon](https://me.dm/@swarnenduiitb2020)
Member-only story
# You Have Been Writing These 15 Python Functions From Scratch. They Already Exist in stdlib
[](https://medium.com/@swarnenduiitb2020?source=post_page---byline--99135bc126f2---------------------------------------)
[DrSwarnenduAI](https://medium.com/@swarnenduiitb2020?source=post_page---byline--99135bc126f2---------------------------------------)
Follow
9 min read
·
3 hours ago
[](https://medium.com/m/signin?actionUrl=https%3A%2F%2Fmedium.com%2F_%2Fvote%2Fp%2F99135bc126f2&operation=register&redirect=https%3A%2F%2Fmedium.com%2F%40swarnenduiitb2020%2Fyou-have-been-writing-these-15-python-functions-from-scratch-they-already-exist-in-stdlib-99135bc126f2&user=DrSwarnenduAI&userId=7d8c943bb150&source=---header_actions--99135bc126f2---------------------clap_footer------------------)
3
[](https://medium.com/m/signin?actionUrl=https%3A%2F%2Fmedium.com%2F_%2Fbookmark%2Fp%2F99135bc126f2&operation=register&redirect=https%3A%2F%2Fmedium.com%2F%40swarnenduiitb2020%2Fyou-have-been-writing-these-15-python-functions-from-scratch-they-already-exist-in-stdlib-99135bc126f2&source=---header_actions--99135bc126f2---------------------bookmark_footer------------------)
[Listen](https://medium.com/m/signin?actionUrl=https%3A%2F%2Fmedium.com%2Fplans%3Fdimension%3Dpost_audio_button%26postId%3D99135bc126f2&operation=register&redirect=https%3A%2F%2Fmedium.com%2F%40swarnenduiitb2020%2Fyou-have-been-writing-these-15-python-functions-from-scratch-they-already-exist-in-stdlib-99135bc126f2&source=---header_actions--99135bc126f2---------------------post_audio_button------------------)
Share
Press enter or click to view image in full size

Yesterday you wrote a function to find the top-N items in a list.
Last week you wrote a function to flatten a nested list.
The week before, you wrote a function to group a list of dicts by a key.
Every single one of those functions already exists in Pytho
URL Source: https://medium.com/@swarnenduiitb2020/you-have-been-writing-these-15-python-functions-from-scratch-they-already-exist-in-stdlib-99135bc126f2?source=rss------python-5
Published Time: 2026-04-23T19:31:01Z
Markdown Content:
# You Have Been Writing These 15 Python Functions From Scratch. They Already Exist in stdlib | by DrSwarnenduAI | Apr, 2026 | Medium
[Sitemap](https://medium.com/sitemap/sitemap.xml)
[Open in app](https://play.google.com/store/apps/details?id=com.medium.reader&referrer=utm_source%3DmobileNavBar&source=post_page---top_nav_layout_nav-----------------------------------------)
Sign up
[Sign in](https://medium.com/m/signin?operation=login&redirect=https%3A%2F%2Fmedium.com%2F%40swarnenduiitb2020%2Fyou-have-been-writing-these-15-python-functions-from-scratch-they-already-exist-in-stdlib-99135bc126f2&source=post_page---top_nav_layout_nav-----------------------global_nav------------------)
[](https://medium.com/?source=post_page---top_nav_layout_nav-----------------------------------------)
Get app
[Write](https://medium.com/m/signin?operation=register&redirect=https%3A%2F%2Fmedium.com%2Fnew-story&source=---top_nav_layout_nav-----------------------new_post_topnav------------------)
[Search](https://medium.com/search?source=post_page---top_nav_layout_nav-----------------------------------------)
Sign up
[Sign in](https://medium.com/m/signin?operation=login&redirect=https%3A%2F%2Fmedium.com%2F%40swarnenduiitb2020%2Fyou-have-been-writing-these-15-python-functions-from-scratch-they-already-exist-in-stdlib-99135bc126f2&source=post_page---top_nav_layout_nav-----------------------global_nav------------------)

[Mastodon](https://me.dm/@swarnenduiitb2020)
Member-only story
# You Have Been Writing These 15 Python Functions From Scratch. They Already Exist in stdlib
[](https://medium.com/@swarnenduiitb2020?source=post_page---byline--99135bc126f2---------------------------------------)
[DrSwarnenduAI](https://medium.com/@swarnenduiitb2020?source=post_page---byline--99135bc126f2---------------------------------------)
Follow
9 min read
·
3 hours ago
[](https://medium.com/m/signin?actionUrl=https%3A%2F%2Fmedium.com%2F_%2Fvote%2Fp%2F99135bc126f2&operation=register&redirect=https%3A%2F%2Fmedium.com%2F%40swarnenduiitb2020%2Fyou-have-been-writing-these-15-python-functions-from-scratch-they-already-exist-in-stdlib-99135bc126f2&user=DrSwarnenduAI&userId=7d8c943bb150&source=---header_actions--99135bc126f2---------------------clap_footer------------------)
3
[](https://medium.com/m/signin?actionUrl=https%3A%2F%2Fmedium.com%2F_%2Fbookmark%2Fp%2F99135bc126f2&operation=register&redirect=https%3A%2F%2Fmedium.com%2F%40swarnenduiitb2020%2Fyou-have-been-writing-these-15-python-functions-from-scratch-they-already-exist-in-stdlib-99135bc126f2&source=---header_actions--99135bc126f2---------------------bookmark_footer------------------)
[Listen](https://medium.com/m/signin?actionUrl=https%3A%2F%2Fmedium.com%2Fplans%3Fdimension%3Dpost_audio_button%26postId%3D99135bc126f2&operation=register&redirect=https%3A%2F%2Fmedium.com%2F%40swarnenduiitb2020%2Fyou-have-been-writing-these-15-python-functions-from-scratch-they-already-exist-in-stdlib-99135bc126f2&source=---header_actions--99135bc126f2---------------------post_audio_button------------------)
Share
Press enter or click to view image in full size

Yesterday you wrote a function to find the top-N items in a list.
Last week you wrote a function to flatten a nested list.
The week before, you wrote a function to group a list of dicts by a key.
Every single one of those functions already exists in Pytho
DeepCamp AI