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

30

u/[deleted] Nov 05 '20

No one mentioned PEP8 yet ?

Have a look, it might help you :

https://www.python.org/dev/peps/pep-0008/

2

u/TheGrapez Nov 05 '20

that's awesome thanks :)

2

u/Gaminguitarist Nov 05 '20

Yea my prof references this whenever it’s comes to script writing. Pretty useful.

2

u/teeaton Nov 06 '20

This is what helped me. I set up my editor (Atom) to run flake8 in the background and it threw up lots of errors in the code. Nothing wrong with it functionally, I'd just not written it the 'proper' way.

What I like about doing it this way is I'm almost forced to fix it as I go, which then develops into good habits. Minor example - when I add a new function, my muscle memory now puts in two blank lines between them not one.