Code in __init__.py, is it bad form?

Steve Holden steve at holdenweb.com
Mon Feb 23 21:03:18 EST 2009


Michael Crute 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?
> 
No, it's absolutely fine. One common usage is to import symbols from
sub-modules so that they are available from a simple import of the package.

regards
 Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC              http://www.holdenweb.com/




More information about the Python-list mailing list