r/pythontips • u/DoomLimpio • Feb 29 '24
Meta code in __init__.py
Hi there!
Recently, I've started working in a new team, and they have several practices that, I won't say are wrong, but seem a bit odd to me. One thing that caught my attention is how they're creating classes/functions inside __init__.py files. In my experience, those files are usually kept empty or just handle basic imports, acting more like an interface when you import the package.
What are your thoughts on this?
13
Upvotes
View all comments
2
u/[deleted] Feb 29 '24
it is supposed to provide the common functionality code for the subpackages/sub files and easy accessibilty for peolpe to access certain code without going much internal. good pratice. nothing wrong with it. just you need to see with which coding pratice/pattern code is written there