[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 Dependency Pitfalls] The Iceberg

Saturday, September 17, 2022

Hey there, The other day I read this quote from a Python developer that made me stop and think: "As a noob with a little programming knowledge already, I've found setting up and installing

[PythonistaCafe] What's in PythonistaCafe for you?

Saturday, September 17, 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

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

Friday, September 16, 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

[PythonistaCafe] Why PythonistaCafe exists

Friday, September 16, 2022

Hey there, In one of my last emails I talked about how some online communities in the tech space devolve over time and turn into cesspools of negativity. This relates directly to how and why I started

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

Friday, September 16, 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*

Software Testing Weekly - Issue 139

Friday, September 30, 2022

Principles of Writing Automated Tests View on the Web Archives ISSUE 139 September 30th 2022 COMMENT Welcome to the 139th issue! Hope you had a nice week so far! There's plenty of great news in

Reader | PC & Console Insights Report, Google Play Games beta expansion, Indie Games Festival winners

Friday, September 30, 2022

What's new for games in Android and Google Play View as webpage Google Play September (Q3) 2022 GAMES QUARTERLY PC & Console Insights Report LEARN MORE Get insights into designing and launching

This Week in Rust 462

Friday, September 30, 2022

Email isn't displaying correctly? Read this e-mail on the Web This Week in Rust issue 462 — 28 SEP 2022 Hello and welcome to another issue of This Week in Rust! Rust is a programming language

Data Science Weekly - Issue 462

Thursday, September 29, 2022

Curated news, articles and jobs related to Data Science. Keep up with all the latest developments Email not displaying correctly? View it in your browser. Issue #462 September 29 2022 Editor's

Google is shutting down Stadia — and Make-A-Video: AI system that generates videos from text

Thursday, September 29, 2022

Issue #905 — Top 20 stories of September 30, 2022 Issue #905 — September 30, 2022 You receive this email because you are subscribed to Hacker News Digest. You can open it in the browser if you prefer.

Google to sunset Stadia in January 2023, will refund hardware purchases

Thursday, September 29, 2022

TechCrunch Newsletter TechCrunch logo The Daily Crunch logo By Christine Hall and Haje Jan Kamps Thursday, September 29, 2022 Today we are mostly listening to acoustic covers of songs we love (a

💻 Issue 325 - Spectre.Console is a .NET Standard 2.0 library that makes it easier to create beautiful console applications.

Thursday, September 29, 2022

This week's Awesome .NET Weekly Read this email on the Web The Awesome .NET Weekly Issue » 325 Release Date Sep 29, 2022 Your weekly report of the most popular .NET news, articles and projects

💎 Issue 332 - Richard Schneeman's How to Open Source book is out! 🤩

Thursday, September 29, 2022

This week's Awesome Ruby Newsletter Read this email on the Web The Awesome Ruby Newsletter Issue » 332 Release Date Sep 29, 2022 Your weekly report of the most popular Ruby news, articles and

💻 Issue 332 - The new wave of Javascript web frameworks

Thursday, September 29, 2022

This week's Awesome JavaScript Weekly Read this email on the Web The Awesome JavaScript Weekly Issue » 332 Release Date Sep 29, 2022 Your weekly report of the most popular JavaScript news, articles

📱 Issue 326 - The hidden impact of ads on your app

Thursday, September 29, 2022

This week's Awesome iOS Weekly Read this email on the Web The Awesome iOS Weekly Issue » 326 Release Date Sep 29, 2022 Your weekly report of the most popular iOS news, articles and projects Popular