osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

__init__ patterns


I saw a thread on reddit/python where just about everyone said they never put code in their __init__ files.

Here's a stackoverflow thread saying the same thing.
https://stackoverflow.com/questions/1944569/how-do-i-write-good-correct-package-init-py-files

That's new to me. I like to put functions in there that other modules within the module need. 
Thought that was good practice DRY and so forth. And I never do 'from whatever import *' 
Ever.

The reddit people said they put all their stuff into different modules and leave init empty.

What do you do?  I like my pattern but I'm willing to learn.

thanks,
--Tim