我正在研究这种结构或python中的一个项目:
 main.py      #must get all the classes from /handlers
 jhpy.py
 handlers/    #files must import jhpy without making meth code in the a, b, ... files
         /a.py
         /b.py
         /...
 entities/    # files in handlers may need these. foo, bar, ... must import jhpy without making creepy code
         /foo.py
         /bar.py
         /...
主要目标是使所有这些提到的事情都起作用,而不必在每个文件中都执行 sys.blah blah。重点是,不要让 a, b, foo, bar, ... 有如此可怕的代码。
有任何想法吗?我很确定我必须做更多的文件。也许我需要添加__init__.py,如果是这样,我应该在这些文件中写什么?这些“额外”文件应该做脏活,这样当我向其中添加新文件时/handlers,/entities它们就会保持干净。