Clarify that packages don't need __init__.py - #1357
Conversation
But still recommend people that are getting started with Python packaging to add them.
willingc
left a comment
There was a problem hiding this comment.
Nice improvement. Thanks @abravalheri.
|
Love the change, thanks! |
I don't :D It is not a big deal, probably can be considered nitpicking, and you can feel free to ignore this. Honestly, I do not follow the logic of this change.
It is not just a recommendation, it is the only way to have the package be a regular package. If the file is not there then it is imported as a namespace package, isn't it? Python still considers it as a namespace package, doesn't it? Maybe there are no practical differences in most of the cases, but the sentence is still incorrect. Maybe the PEP says that the initializer can be omitted but it seems to me very much against the spirit of the PEP (what its author stated later on [1] [2]). Is the intention of mentioning that If I recall correctly I have more than once helped fix people's projects by telling them to add missing
Unless the behavior of those has changes since last time I checked (which was a long time ago, for sure):
|
|
Hi, @sinoroc the idea was a bit different: the recommendation is for people to add We can further clarify that if you prefer. I don't know about |
This is a follow up on #1342: the tutorial implies that a Python package requires an
__init__.pyfile.I think that is the best to avoid this implication, otherwise we might "mis-educate" "packaging beginners" from the start.
The idea of this change is to introduce minimal rewording and a footnote.
The terms "regular package" and "namespace package" were introduced in PEP 420, which is also very intentional when it comes to equating regular and namespace packages:
The change still recommends people that are getting started with Python packaging to add
__init__.pyas a result of the discussion in #1292: the general understanding in the community is that some tools might not fully support namespace packages yet (or be a bit more fussy about it) - although I cannot point out examples of these tools from the top of my mind...Closes #1292.