Hacker News new | ask | show | jobs
by earthboundkid 2239 days ago
There's also the thing where you used to need to have a magic __init__.py file for a folder to be a considered as a module, but now it's optional, although I still have no idea what the formula is for when Python decides something is a module…
1 comments

It's not really optional. There's just this new thing called namespace packages which is not quite the same. I don't fully understand what it's for yet.
Namespace packages let you ship `foo.bar` and `foo.baz` separately. `bar` and `baz` are really two separate packages that are both part of the `foo` namespace. `foo` is not a real package.

They are not new but implicit namespace packages are new-ish. Before 3.3 it was more complicated to set up, now you just omit __init__.py from `foo`.

I don't see any reason to use this if `foo` is shipped as a single package.

If the implementation is hard to explain, it's a bad idea.

If the implementation is easy to explain, it may be a good idea.

This is right.