DEV Community

Cover image for How I Organise My Python Code

How I Organise My Python Code

Pastor Emmanuel on May 29, 2024

New update added to the private methods. Writing code is more of an art than a science, I must opine. It's important to write well-refined, log...
Collapse
 
ebcefeti profile image
E. B. Cefeti

I feel like you might be over-buying into the OO Python approach a bit? A lot of these are features that would be better communicated with a combination of docstrings, type hints, etc., rather than overloading internal representations.

Collapse
 
pastorenuel profile image
Pastor Emmanuel

Hi Cefeti,

Thank you for your comment.

Maybe you missed the overall goal of the post. You don't have to overload the internal representations. But in the case where you do, following the order expressed, helps your code to be better organised. The focus of this post is more around organising your python class methods. We will discuss writing better docstrings and type hinting in subsequent posts. I hope this clears your concerns

cheers !

Collapse
 
sein_digital profile image
Błażej Adamczyk

Nice post! That's pretty neat approach. I wonder how would you organize your project directory tree, and app architecture :) Care to share?

Collapse
 
pastorenuel profile image
Pastor Emmanuel

Thank you Blazej for your comment.

Sure, I will create a subsequent discussing project organisation.

cheers mate !

Collapse
 
incrementis profile image
Akin C.

Hello Pastor Emmanuel,

thank you for your article.
I've been programming with Python quite a bit lately.
Luckily, at this point in my usage, I have yet to program any classes in Python, but it is still quite insightful to see how this can be achieved in a clean manner.

Collapse
 
pastorenuel profile image
Pastor Emmanuel

Thank you Akin. Glad you find it insightful 😊

Collapse
 
linkbenjamin profile image
Ben Link

Thanks for this, good explanation and easy to see how you can organize your thoughts!

Collapse
 
pastorenuel profile image
Pastor Emmanuel

I'm glad you find it helpful Ben.

Collapse
 
noscrubs profile image
No Scrubs

amazing post

Collapse
 
pastorenuel profile image
Pastor Emmanuel

Thank you for the comment

Collapse
 
edward_thomas profile image
Edward Thomas

Nice, I like the public methods.