News for hackers. Stuff that matters.
Re:Say “no” to import side‐effects in Python by bjt on Saturday April 05, 2014 @10:23AM (#7537147)
In case a non-Python programmer is reading this and misunderstood your comment, I'll point out that having code in __init__.py and having import-time side effects are completely unrelated.

When I put any code in __init__.py, it's usually just to make the import path shorter for the programmer using my library. So instead of this:

from mypackage.models import Foo

...users can do this:

from mypackage import Foo

And all it takes to support that is putting this in mypackage/__init__.py:

from mypackage.models import Foo

A quick Googling of "Should I put code in __init__.py" shows a lot of people doing that same pattern. It doesn't show a consensus of people saying that more substantial code in __init__.py is an anti-pattern.

Re:Say “no” to import side‐effects in Python by atilaneves on Saturday April 05, 2014 @11:36AM (#7537345)
To me you're using __init__.py right. The person who wrote the library I mentioned really isn't.