[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

Key phrases

Older messages

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

Thursday, October 6, 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"?

Wednesday, October 5, 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 Mastery] What does it mean to "master" Python?

Tuesday, October 4, 2022

Hey there, A couple of years ago I'd become quite interested in martial arts. Hours upon hours of watching "The Karate Kid" growing up must've taken their toll on me... And so, I

[Sublime + Python Setup] Sublime Text is just a blank canvas…

Monday, October 3, 2022

Hey there, When I became serious about optimizing Sublime Text with plugins, it was hard for me to separate the wheat from the chaff. Without a real guideline or roadmap I resorted to installing *any*

[Sublime + Python Setup] Grumpy old greybeard with a whitespace problem

Sunday, October 2, 2022

One fateful day, the Agile Gods that be decided to “add some firepower” to my little team… And so, developer Paul joined (name changed to protect the guilty). Before I dive into this story, let me ask

LW 64 - Build a Shopify Store with Next.js + Tailwind CSS

Tuesday, November 29, 2022

Build a Shopify Store with Next.js + Tailwind CSS Shopify Development news and articles Issue #64 - 11/29/2022 Read Online Liquid Weekly News & Articles Build a Shopify Store with Next.js +

Elon Musk claims Apple 'threatened to withhold’ Twitter app

Tuesday, November 29, 2022

The Morning After Now available on your smart speaker and wherever you get your podcasts Apple Podcasts | Spotify | Google Play | iHeart Radio It's Tuesday, November 29, 2022. Elon Musk claims that

Those Giant Car Bows Are Totally Real and You Can Buy One

Tuesday, November 29, 2022

Read in Browser Logo for Review Geek November 29, 2022 If you've ever bought a gigantic present for someone so large that wrapping it in paper would be about as much effort as painting your house,

Post from Syncfusion Blogs on 11/29/2022

Tuesday, November 29, 2022

New blogs from Syncfusion Preact vs. React Top 15 VS Code Extensions Every Developer Should Know More from the Syncfusion Ecosystem Bold Reports: Paginated Reports and Analytics Bold Desk: Customizable

📃 Edge#247: Classifying ML Interpretability Methods

Tuesday, November 29, 2022

In this issue: we classify ML interpretability methods; we explore the building blocks of interpretability by Google Research; we explain TensorWatch, an open-source framework for debugging ML models.

Tesla Model 3 redesign 🚗, new GPT-3 released 🤖, lessons from being laid off 👨‍💻

Tuesday, November 29, 2022

Telsa is developing a revamped version of the Model 3. Sign Up | View Online | Sponsor Daily Update 2022-11-29 New survey reveals % of business decisions made based on actual data (Sponsor) Is '

Give back to open source on Giving Tuesday, 3 Git commands to level up your skill, and more

Tuesday, November 29, 2022

Write a C++ extension module for Python Write a C++ extension module for Python Opensource.com THE LATEST Give back to open source on Giving Tuesday Here are 18 ways to support and donate to free and

Power BI Weekly #184 - 29th November 2022

Tuesday, November 29, 2022

Power BI Weekly Newsletter Issue #184 powered by endjin Welcome to the 184th edition of Power BI Weekly! Absolutely no word from the Power BI team this week, so we'll jump straight into the

DeveloPassion's Newsletter - Black Friday Experiments

Tuesday, November 29, 2022

Hello everyone! I'm Sébastien Dubois, your host. You're receiving this email because you signed up fo DeveloPassion's Newsletter - Black Friday Experiments By Sébastien Dubois • Issue #97 •

[Last chance to register] Future-proof your observability platform with OpenTelemetry and Elastic

Tuesday, November 29, 2022

Join our Nov. 30 webinar to learn more. ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ elastic | Search. Observe. Protect Future-proof your observability platform with OpenTelemetry and Elastic