5 tips for CLEAN Python code

  Рет қаралды 3,256

Carberra

Carberra

Күн бұрын

Пікірлер: 16
@gardnmi
@gardnmi 3 ай бұрын
Good stuff, one rule I have is to never use classes unless you have mutable data where you need to track it's state. Even then you may not need a class. It's easier to test, debug, and maintain function vs classes.
@Carberra
@Carberra 3 ай бұрын
Thank you! Honestly that's a pretty good rule.
@largewallofbeans9812
@largewallofbeans9812 3 ай бұрын
I must disagree with you on this. Using classes means that you can handle a bunch of objects that have predefined operations rather than big if-elif trees with the same operations that may take a while to select. It's hard to explain in writing but in the project I'm working on, it makes performance slightly better.
@epicmoofish3726
@epicmoofish3726 3 ай бұрын
@@largewallofbeans9812if you are worried about performance you are using the wrong language
@justtil6749
@justtil6749 3 ай бұрын
Classes allow for dependency inflection, and therefore better testing
@pythonwithjames
@pythonwithjames 3 ай бұрын
I really agree with the idea of splitting up complex functions, makes testing a lot easier too!
@Carberra
@Carberra 3 ай бұрын
Oh yeah testing for sure. There is actually something called cyclomatic complexity that can be used to measure the complexity of a piece of code. I intentionally chose to not mention it, but now kinda wish I had. Oh well lmao.
@synchro-dentally1965
@synchro-dentally1965 3 ай бұрын
"y" no love?
@ronalddebruijn613
@ronalddebruijn613 3 ай бұрын
Thanks, I like your practicality!
@rivencooler1951
@rivencooler1951 3 ай бұрын
Good stuff and you got me idea on how to write the clean code. I have a request, can you make a view on your VS code setup/cnfiguration?
@Carberra
@Carberra 3 ай бұрын
Thank you! And I already have! There's a link in the description.
@KavyanshKhaitan
@KavyanshKhaitan 3 ай бұрын
At 3:16 In my opinion, shifting the return False to the next line makes it less readable, and it should stay in an else block. BUT, the part after that makes it more readable.
@Carberra
@Carberra 3 ай бұрын
Yeah it wasn't the best example for that specifically, but I just wanted to show off that's generally how it would work. It would work best where there were multiple negative cases you needed to pick off.
@KavyanshKhaitan
@KavyanshKhaitan 3 ай бұрын
@@squishy-tomato yeah thats prob why. Since I never read code in that manner, it looks wierd.
Generics are VITAL in typed Python
16:54
Carberra
Рет қаралды 9 М.
Every parent is like this ❤️💚💚💜💙
00:10
Like Asiya
Рет қаралды 12 МЛН
8 Python Coding Tips - From The Google Python Style Guide
17:12
ArjanCodes
Рет қаралды 158 М.
5 Tips for Writing Clean Python Code
25:59
ArjanCodes
Рет қаралды 26 М.
Avoid These BAD Practices in Python OOP
24:42
ArjanCodes
Рет қаралды 55 М.
The COMPLETE guide to Python properties
15:30
Carberra
Рет қаралды 3,5 М.
Ruff is the FUTURE of Python development
14:25
Carberra
Рет қаралды 134 М.
Python: A Quick Guide To Type Annotations (ft. Mypy)
11:25
Indently
Рет қаралды 32 М.
5 Tips To Organize Python Code
12:16
Tech With Tim
Рет қаралды 236 М.
Python 3.13's new REPL is AMAZING
10:21
Carberra
Рет қаралды 55 М.
python 3.13 release highlights
49:56
anthonywritescode
Рет қаралды 17 М.
The CORRECT way to work with temporary files in Python
11:48