r/learnpython • • Nov 05 '20

How does one learn to make well-structured programs? Mine are dumpster-fires.

So I just (kind-of) finished reading Automate The Boring Stuff With Python, and for the past month I've felt like a big-brained super-hero automating myself out of a job (Data Analyst).

The problem is, I feel I missing something along the way. I don't understand the proper way to use functions, what a class is, why people have multiple files in a program, how/why people use GitHub...probably some other things I haven't discovered yet.

They all seem to be related to organization? Is there a "How To Structure Your Python Stuff With Python" book?

478 Upvotes

98 comments sorted by

View all comments

1

u/snugglyboy SkillLevels.INTERMEDIATE Nov 05 '20

Lots of great comments already. I'll just add that my wife finished Automating the Boring Stuff, and I helped her through it, and there's a lot the book doesn't cover that a normal programming book or course would. I don't blame you for feeling unclear about functions, and the book doesn't cover classes at all, which is a huge topic that can't just be explained in a few sentences. Not that it's a bad book by any means, but I think the goal of that book is to get you up and running quickly, to see the different ways you can automate things, rather than really teach you Python.

So now that you've had a solid intro to Python, you may want to find a more technical book that delves deeper into the topics. I think when you have a solid understanding of python, a lot of the structure falls into place. When I'm learning a language, I always need to read a couple books before I really feel confident with a language. I'm doing that now with C++.

That said, my process for writing a program is usually to write a huge mess of code that is embarrassingly horrible, just to get it working first. Often, in writing code, you encounter logical problems and design challenges you hadn't thought about initially. So it's my process to encounter all of that in the messy phase, and then once it's all working, I know what I'm dealing with, and can go back and clean or re-write things much more elegantly using what I've learned along the way.