Hacker News new | ask | show | jobs
by lutostag 2388 days ago
Always one of the good articles to link to when creating a Python repo from scratch.

Should mention that __init__.py is not needed for python 3.3+ anymore (just found that out this week myself to my surprise) so for projects where backwards compatibility is not required you can stop creating extra blank files if you don't need them.

https://stackoverflow.com/questions/37139786/is-init-py-not-...

2 comments

Although, beware that you may need to change `find_packages()` to `find_namespace_packages()` in your setup.py.

I get burned by that one a lot!

That's really not recommended. A lot of behaviors are subtly affected by failing to have init files.
Like what?
Not op but I have personally noticed that doing a ‘python setup.py install’ doesn’t correctly import modules unless you have an __init__.py file. It’s possible I could be doing something wrong however.
Mypy sometimes uses init files to understand internal imports.