I like the Java convention of having one public class for each file, even if sometimes there are good reasons to put more than one public class in one file. In my case, I have alternative implementations of the same interface. But if I put them in separate files, I would have redundant names in the import statements (or misleading module names):
import someConverter.SomeConverter
whereas someConverter will be the name of the file (and module) and someConverter name of the class. It looks pretty unflattering to me. To put all the alternative classes in a single file, you get a more meaningful import statement:
import converters.SomeConverter
But I'm afraid that the files will become quite large if I put all the related classes in one module file. What is Python best practice? Is one class for each file unusual?
python module class package
deamon 01 Oct 2018-10-10 19:58
source share