r/learnpython • u/beb0 • Feb 04 '26
Writing professional level python
I've only ever used python with scripts, advent of code and leetcode, how can I learn to write python to a professional level, I've worked within web and done some Django tutorials. However I am interviewing and want to use python I am also using it such as
def function(some_param: type):
do something
return something
def function_2(some_param: type):
do something
return something
var = function()
function_2(var)What should I be doing to make this code look more senior level
2
Upvotes
2
u/Sure-Passion2224 Feb 04 '26
Like all programming languages - you learn and improve by doing.
As I'm writing this I'm also reading the comment from u/AssociationLarge5552 and thinking... this person knows what they're talking about. Professional level code is easy to maintain and self documenting. ** Insert all of the points made by u/AssociationLarge5552 here. **
For readable maintainable code the following pattern is common for a lot of reasons.
Classes, Functions, and Methods are prefixed with a brief block comment that identifies
the Object,
what it's for,
and what the data contract (I/O values and types) is.
Inline comments are limited, but provide signage regarding where you are in the process or what the next block of several lines of code is supposed to do.
Logical description comments exist only for particularly complex scenarios.
Variable names are meaningful (idxCar) not just a single letter as you see way too often in loop structures.
If you do the same thing more than a couple of times it's worth thinking about as a separate method or function.
If you use it in more than one Class then make it available in a common Class.
You shouldn't need epic novel length commentary if your code is readable. Any competent developer should be able to read your code and comprehend what you intended.