Transistion from module to package and __init__.py

Ethan Furman ethan at stoneleaf.us
Wed May 5 14:02:35 EDT 2021


On 5/4/21 7:20 PM, Chris Nyland wrote:

 > Here is
 > where I my primary design question comes in. As organized now as described
 > to import and use the package I need
 >
 > from database import database
 >
 > or I have to put in the init file
 >
 > from database import *
 >
 > Either of these still leaves a database.database namespace laying about and
 > to me it just seems untidy. So for a while now I have taken to converting
 > my module, in this example database.py, to the __init__.py of the package.

 > So I was hoping to get
 > feed back from a wider audience about if there are any issues with this
 > type of design that I just haven't encounter yet or find out what other
 > people do with this same problem.

This is the same method I use, and it works fine for smaller packages.  I do have one package, dbf, that I am in the 
process of converting to multiple files simply because there is so much (10k lines for me, YMMV).

--
~Ethan~


More information about the Python-list mailing list