Real Python - artisanal from-scratch programmers

Hey there,

The other day I got this question from Newsletter member Newvick in my email inbox:

~~~

I found your post on books for people looking to move past the beginner's stage in python, and it was very timely for me.

With that goal in mind, one problem I have is:

When do you use libraries/frameworks and when do you make things from scratch? (whether for learning or developing something for a client/work)

~~~

When to code functionality from scratch and when to use libraries—that's a big question.

There's a fine balance you need to strike here:

When I learned programming I was "reinventing wheels" left and right— and it pushed my abilities forward quickly.

I was constantly writing all kinds of existing functionality from scratch and it was the right thing to do because it helped me grow my skills.

It was a great learning exercise.

But there comes a time in a developers life when that strategy doesn't work so well any more—

Eventually I got diminishing (learning) returns from trying to build everything from scratch.

Plus my development pace was dog-slow.

I spun my wheels—and my productivity began to plateau.

Another downside is this:

It's difficult to work on a team when someone always wants to approach every single problem from first principles. It can drive people NUTS.

These days I try to use (good and well-documented!) third-party libraries where possible.

But again, you'll want to find a balance there too:

I DO NOT recommend you pull in an external dependency for every little thing—

The people who got burned by the NodeJS "left-pad" incident know what I'm talking about...

Actually, this is a fun (ahem) "disaster" story by itself:

There was a little library called "left-pad" on Npm, the NodeJS package repository.

That "library" contained maybe 20 lines of code in total, but it was used in—literally—MILLIONS of JavaScript projects.

It added a tiny piece of functionality that was frequently needed but wasn't a part of the NodeJS standard library.

When the developer who created "left-pad" closed his Npm account last year, "left-pad" was suddenly no longer available for download...

And guess what happened to the dependency install process on projects using "left-pad"...

Well, it came to a SCREECHING HALT.

It was quite crazy. Even some newspapers reported about it.

And there was a lot of "bruhaha" about the NodeJS packaging system.

(But to tell you the truth the same thing could happen with PyPI.)

I guess the moral of the story is:

"Do use 3rd-party libraries and frameworks, but don't overdo it and only go for the trustworthy ones."

Sometimes it's just tough as nails to strike the right balance here...

By the way, if you want to dig deeper—I've got a complete step-by-step workflow for researching and making those dependency decisions (and explaining them to your team/manager) in my "Managing Python Dependencies" course.

But to bring this to a close and answer the original question:

As a rule of thumb, I'd only consider a "let's write it from scratch" strategy IF time is not an issue.

(Which it rarely is outside a pure learning environment.)

Happy Pythoning!

— Dan Bader

Older messages

New Python tutorials on Real Python

Saturday, September 26, 2020

Hey there, There's always something going on over at realpython.com as far as Python tutorials go. Here's what you may have missed this past week: Python Practice Problems: Get Ready for Your

New Python tutorials on Real Python

Saturday, September 19, 2020

Hey there, There's always something going on over at realpython.com as far as Python tutorials go. Here's what you may have missed this past week: Plot With Pandas: Python Data Visualization

Learn Python in 21 days!!!!11

Friday, September 18, 2020

Hey there, One of the first programming books I ever bought was "Teach Yourself C in 21 Days." This four pound tome came with a CD-ROM that included an ancient version (3.1) of the Borland

New Python tutorials on Real Python

Saturday, September 12, 2020

Hey there, There's always something going on over at realpython.com as far as Python tutorials go. Here's what you may have missed this past week: Video Subtitles & Transcripts Now

What Pythonistas can learn from bestselling horror authors

Sunday, September 6, 2020

Hey there, I just finished reading Stephen King's "On Writing." It's a great little book where he shares some of the writing advice and stories he's picked up over the course of

You Might Also Like

Import AI 399: 1,000 samples to make a reasoning model; DeepSeek proliferation; Apple's self-driving car simulator

Friday, February 14, 2025

What came before the golem? ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏

Defining Your Paranoia Level: Navigating Change Without the Overkill

Friday, February 14, 2025

We've all been there: trying to learn something new, only to find our old habits holding us back. We discussed today how our gut feelings about solving problems can sometimes be our own worst enemy

5 ways AI can help with taxes 🪄

Friday, February 14, 2025

Remotely control an iPhone; 💸 50+ early Presidents' Day deals -- ZDNET ZDNET Tech Today - US February 10, 2025 5 ways AI can help you with your taxes (and what not to use it for) 5 ways AI can help

Recurring Automations + Secret Updates

Friday, February 14, 2025

Smarter automations, better templates, and hidden updates to explore 👀 ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏

The First Provable AI-Proof Game: Introducing Butterfly Wings 4

Friday, February 14, 2025

Top Tech Content sent at Noon! Boost Your Article on HackerNoon for $159.99! Read this email in your browser How are you, @newsletterest1? undefined The Market Today #01 Instagram (Meta) 714.52 -0.32%

GCP Newsletter #437

Friday, February 14, 2025

Welcome to issue #437 February 10th, 2025 News BigQuery Cloud Marketplace Official Blog Partners BigQuery datasets now available on Google Cloud Marketplace - Google Cloud Marketplace now offers

Charted | The 1%'s Share of U.S. Wealth Over Time (1989-2024) 💰

Friday, February 14, 2025

Discover how the share of US wealth held by the top 1% has evolved from 1989 to 2024 in this infographic. View Online | Subscribe | Download Our App Download our app to see thousands of new charts from

The Great Social Media Diaspora & Tapestry is here

Friday, February 14, 2025

Apple introduces new app called 'Apple Invites', The Iconfactory launches Tapestry, beyond the traditional portfolio, and more in this week's issue of Creativerly. Creativerly The Great

Daily Coding Problem: Problem #1689 [Medium]

Friday, February 14, 2025

Daily Coding Problem Good morning! Here's your coding interview problem for today. This problem was asked by Google. Given a linked list, sort it in O(n log n) time and constant space. For example,

📧 Stop Conflating CQRS and MediatR

Friday, February 14, 2025

​ Stop Conflating CQRS and MediatR Read on: m​y website / Read time: 4 minutes The .NET Weekly is brought to you by: Step right up to the Generative AI Use Cases Repository! See how MongoDB powers your