Code in __init__.py, is it bad form?

Carl Banks pavlovevidence at gmail.com
Mon Feb 23 22:16:54 EST 2009


On Feb 23, 5:41 pm, Michael Crute <mcr... at gmail.com> wrote:
> Is it bad form (i.e. non-pythonic) to have code in your __init__.py
> files? I know this is subjective so I'm just looking for the general
> consensus. I've heard both sides of the story and I personally feel
> its okay if the code pertains to the whole module but have an open
> mind about the matter. If you object to code in __init__.py why, and
> what alternatives do you propose?


Well, I don't like when __init__ "helpfully" imports stuff I don't
need.  However, most single modules have lots of code I don't need,
too, and I never concern myself with them, so it's probably a
misplaced irk.

Go ahead and use it.


Carl Banks



More information about the Python-list mailing list