How to import all things defined the files in a module directory in __init__.py?

Chris Angelico rosuav at gmail.com
Thu Sep 22 12:25:05 EDT 2016


On Fri, Sep 23, 2016 at 1:50 AM, Peng Yu <pengyu.ut at gmail.com> wrote:
>
> This will make refactoring easy. If everything is explicit, when one
> do refactoring, at two places need to be changed which can be a
> burden.

So you want it to be easy to move stuff around between files in a
package? Sounds like you don't actually have a package at all - you
have a single module that you're splitting across several files.

How big would this file be if you simply put it all into one .py file
and got rid of the package altogether? For reference, the Decimal
module (ignoring the C accelerator) is over six thousand lines of
code, as a single module. Now, that might be pushing the boundaries a
bit, but certainly there's no reason to split a file that's under a
thousand lines of code. Just keep it all in one file, and organize it
using marker comments - that way, there's no API change as you reorder
stuff.

ChrisA



More information about the Python-list mailing list