[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, August 18, 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 Dependency Pitfalls] How to set the world on fire

Thursday, August 18, 2022

Hey there, #1 on my list of dependency management pitfalls is there for a good reason: It lead to a single developer causing mayhem and breaking thousands of open-source projects around the world in

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

Wednesday, August 17, 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] A total mess?

Wednesday, August 17, 2022

Hey there, Recently I watched a Pythonista ask for advice on setting up a Python project on his work machine. This new developer had some prior experience with NodeJS and had just started to get his

[Python Mastery] What does it mean to "master" Python?

Tuesday, August 16, 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

You Might Also Like

Python Weekly - Issue 647

Thursday, April 25, 2024

View this email in your browser Python Weekly Welcome to issue 647 of Python Weekly. Let's get straight to the links this week. From Our Sponsor Get Your Weekly Dose of Programming A weekly

Web Tools #562 - Voilà Review, CSS Tools, Media, React Native

Thursday, April 25, 2024

WEB VERSION Issue #562 • April 25, 2024 The following is a paid product review for Voilà, an AI assistant for the browser that enables you to improve your writing, coding, brainstorming, and research

Everyone wants to build the AI dev tool of the future

Thursday, April 25, 2024

A new startup called Augment has raised north of $250 million to build AI-powered dev tools. View this email online in your browser By Alex Wilhelm Thursday, April 25, 2024 Welcome to TechCrunch AM!

7 reasons to use Copilot over ChatGPT

Thursday, April 25, 2024

Coros Vertex 2S; Top 5 news apps; New Yeedi M12 Pro+ -- ZDNET ZDNET Tech Today - US April 25, 2024 placeholder 7 reasons I use Copilot instead of ChatGPT I reach for Copilot every day, and here's

Why they signed up for my Private AI Mentorship

Thursday, April 25, 2024

There are 3 reasons: use cases, accountability, and time. ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌

wpmail.me issue#664

Thursday, April 25, 2024

wpMail.me wpmail.me issue#664 - The weekly WordPress newsletter. No spam, no nonsense. - April 24, 2024 Is this email not displaying correctly? View it in your browser. News & Articles WordPress

📧 Modular Monolith Architecture is now LIVE! 🎉

Thursday, April 25, 2024

​ MMA is now LIVE! The day has finally come. ​Modular Monolith Architecture is now open for enrollment. ​ I can't wait for you to see everything I prepared! 10 in-depth chapters 60+ high-quality

Testing the Rabbit R1's AI assistant

Thursday, April 25, 2024

The Morning After It's Thursday, April 25, 2024. Back in January, startup Rabbit revealed its first device at CES 2024. The R1 is an adorable, vibrant orange AI machine with a camera, scroll wheel,

Zero-Day Alert: State-Sponsored Hackers Exploting Two Cisco Flaws for Espionage

Thursday, April 25, 2024

THN Daily Updates Newsletter cover Coding with AI For Dummies ($18.00 Value) FREE for a Limited Time Boost your coding output and accuracy with artificial intelligence tools Download Now Sponsored

Post from Syncfusion Blogs on 04/25/2024

Thursday, April 25, 2024

New blogs from Syncfusion How BoldSign Improved HR Operations at Syncfusion By Syncfusion HR Team Let's see how Syncfusion's BoldSign revolutionizes HR operations with seamless document