Code in __init__.py, is it bad form?
mcrute at gmail.com
Mon Feb 23 21:21:57 EST 2009
On Mon, Feb 23, 2009 at 9:03 PM, Steve Holden <steve at holdenweb.com> wrote:
> 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.
Yeah, I use it often for that I'm talking more about stuff like
utility functions, main methods, etc...
Michael E. Crute
God put me on this earth to accomplish a certain number of things.
Right now I am so far behind that I will never die. --Bill Watterson
More information about the Python-list