[Python Mastery] The hidden costs of "copy-paste" Python programming

Hey there,

Here's a development story that plays out thousands of times each day:

Avid Pythonista Max is working on a function to find the 10 oldest files in a nested directory hierarchy.

He needs to solve this problem to help automate a complicated (manual) workflow for one of his clients, an accounting firm.

So Max pulls up Firefox and punches some keywords into the StackOverflow search box—

And, lo and behold, a helpful looking answer pops out at him among the first few search results.

The "answer" involves about 20 lines of terse Python code. It uses the os.walk function and the heapq module internally.

Max doesn't know much about those—but the guy who wrote the answer has a reputation score of 49,717...

Max really needs to get this file search thing working so he copies the relevant lines of code from the StackOverflow answer and pastes them into his code editor.

Some slight renaming and adding a few imports later it's "Mission Accomplished!" and Max can wander off and grab another cup of coffee.

Great job!

That's how programming is supposed to work these days, right?

I'm not so sure...

Becoming "stuck" and needing to do some research is a daily occurrence for any programmer I know (myself included).

But every time that happens, you can make an impactful LONG-TERM CHOICE:

Do you jump to the first StackOverflow answer and implement whatever is suggested there—

Or do you use the answer as inspiration and take the time to learn a novel concept from the ground up, that you can then use to solve the problem at hand?

Either option solves the problem...and both have their applications in practice.

Here's how I like to think about this choice:

Taking the time to study a problem is like *improving your vocabulary* in a foreign language.

You build up a body of knowledge over time that you can benefit from in the long run.

Copy-and-pasting the first answer that seems reasonable, on the other hand, is like *hiring a translator*.

Yes, it solves the problem immediately, but you'll depend on the translator FOREVER.

There's a lot of "hire a translator"-style advice out there in the programming world.

And it's often to your detriment.

I'm not trying to knock StackOverflow by the way. It's a resource I use almost daily.

My point is:

When you look at the whole picture, convenience always comes with hidden costs.

In the long run, "building your vocabulary" is the much better strategy to achieve fluency.

This is the exact philosophy behind my book "Python Tricks: A Buffet of Awesome Python Features".

It's NOT a tome of code snippets to mindlessly copy and paste from (which are a dime a dozen).

Instead, you'll understand Python's best practices from the ground up—with a clear and logical narrative, and step-by-step examples:

>> Click here to see how to take your Python skills to the next level (without resorting to Stack Overflow "copy pasta")

Happy Pythoning!

— Dan Bader

Older messages

[Sublime + Python Setup] why Atom can’t replace Sublime

Friday, September 30, 2022

Hey there, "In a nutshell, Atom is a Sublime Text editor that just got better." When I read this quote I got so worked up I nearly fell off my chair. Because every time I've tried Atom or

[Python Dependency Pitfalls] "Re-inventing the wheel" disease

Friday, September 30, 2022

Hey there, PyPI, the Python packaging repository, now contains more than 100000 third-party packages in total. That's an *overwhelming* number of packages to choose from... And this feeling of

[Python Mastery] Learn Python in 21 days!!!!11 (what a lie)

Friday, September 30, 2022

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

[Python Mastery] The secret to "ethical self-promotion"?

Thursday, September 29, 2022

Hey there, Here's some food for thought: There's a difference between *doing* a great job as a Python developer, and *to be seen doing* a great job. Being a skilled developer among peers—and

[Python Dependency Pitfalls] Artisanal "from-scratch" development

Thursday, September 29, 2022

Hey there, The other day I got this question from Newsletter member Newvick in my email inbox: ~~~ I'm trying to get past the beginner's stage in Python and one problem I have is: When do you

You Might Also Like

Is the wind going out of the AI sails?

Friday, April 19, 2024

Rippling vacuums up venture capital and Ramp bags more millions View this email online in your browser By Haje Jan Kamps Friday, April 19, 2024 Image Credits: Getty Images / Carol Yepes Welcome to

Llama 3 is out - Weekly News Roundup - Issue #463

Friday, April 19, 2024

Plus: brand-new, all-electric Atlas; AI Index Report 2024; Microsoft pitched GenAI tools to US military; Humane AI Pin reviews are in; debunking Devin; and more! ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏

Daily Coding Problem: Problem #1417 [Easy]

Friday, April 19, 2024

Daily Coding Problem Good morning! Here's your coding interview problem for today. This problem was asked by Wayfair. You are given a 2 x N board, and instructed to completely cover the board with

Charted | How Hard Is It to Get Into an Ivy League School? 🎓

Friday, April 19, 2024

We detail the admission rates and average annual cost for Ivy League schools, as well as the median SAT scores required to be accepted. View Online | Subscribe Presented by: Discover the motivations

Dark Matter & Tortured Poets

Friday, April 19, 2024

New music releases aren't what they used to be -- for good and bad. Dark Matter & Tortured Poets By MG Siegler • 19 Apr 2024 View in browser View in browser New music releases in 2024 are a

Impact of AI on Product Management

Friday, April 19, 2024

​ Impact of AI on Product Management The rise of the AI Product Manager. Product managers have always championed customer's needs. However, with AI, the job requires new technical and ethical

⚙️ Zuck has entered the chat(bot)

Friday, April 19, 2024

Plus: AI video's coming to mobile! ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌

Noonification: Just Made my First Dollar With My SaaS After Quitting my Job

Friday, April 19, 2024

Top Tech Content sent at Noon! Get Algolia: AI Search that understands How are you, @newsletterest1? 🪐 What's happening in tech this week: The Noonification by HackerNoon has got you covered with

From Not to Hot 🔥7 Practices to Land a Trending Story

Friday, April 19, 2024

Discover the Insider Secrets to Elevate Your Story's Success! 🚀 ͏ ‌  ͏ ‌  ͏ ‌  ͏ ‌  ͏ ‌  ͏ ‌  ͏ ‌  ͏ ‌ ͏ ‌  ͏ ‌  ͏ ‌  ͏ ‌  ͏ ‌  ͏ ‌  ͏ ‌  ͏ ‌ ͏ ‌  ͏ ‌  ͏ ‌  ͏ ‌  ͏ ‌  ͏ ‌  ͏ ‌

iOS Dev Weekly - Issue 657

Friday, April 19, 2024

What's the easiest and least hassle path to launching a custom app store in the EU? 🏪 View on the Web Archives ISSUE 657 April 19th 2024 Comment You probably already saw this week's