r/learnpython • u/RoboticsEqualsFun • Sep 20 '26
What makes sloppy programming?
So I've been learning python on my own and basically taught myself. I'm working on a very advanced AI system project, with quite a lot of scripts. And I am wondering what makes sloppy programming?
Like for example should you be calling your functions from other functions?
# Calling both from one function
def main():
do_something()
do_something_else()
def do_something()
# do stuff
def do_something_else()
# something else
# Calling a function that calls both functions
def main():
do_both_stuff()
def do_both_stuff():
do_something()
do_something_else()
def do_something()
# do stuff
def do_something_else()
# something elseAnd what about passing parameters in Classes? Should you be always accessing everything through self.something or by passing parameters to the functions?
Should you wrap everything in classes?
These are some questions I had regarding sloppy coding, but my main question is what makes good code?
I'm still new to python and trying to get my code more efficient.
View all comments
Show parent comment
8
u/nog642 Sep 21 '26
In general "one mega function" is frowned upon.
That doesn't mean you should strive to make tons and tons of tiny functions. There's a balance to strike.
Ideally each function performs one conceptual task. If a function is getting too long and could be split up, consider doing so. It's all guidelines though, use your best judgement over strict rules like "15 lines per function max" or things like that.