The Pythonic way of organizing modules and packages

前端 未结 5 1555
天命终不由人
天命终不由人 2020-12-12 16:35

I come from a background where I normally create one file per class. I organize common classes under directories as well. This practice is intuitive to me and it has been pr

5条回答
  •  眼角桃花
    2020-12-12 16:50

    In a mid-sized project, I found myself with several sets of closely related classes. Several of those sets are now grouped into files; for example, the low-level network classes are all in a single network module. However, a few of the largest classes have been split out into their own file.

    Perhaps the best way to start down that path from a one-class-per-file history is to take the classes that you would normally place in the same directory, and instead keep them in the same file. If that file starts looking too large, split it.

提交回复
热议问题