How many classes should I put in one file?

Asked 2 years ago, Updated 2 years ago, 131 views

In Java, I only put one public class in one file I don't know what to do with Python.

Some modules have only one class There's a lot on some modules.

What is the standard for making a module in Python?

abstract-class python

2022-09-21 16:17

1 Answers

Each Python file is called a module, and the directory structure that manages multiple modules in layers is called a package.

Unlike Java, a Python module can have multiple classes. Because the criteria for making Python modules is "make sense" rather than the number of classes.

It's weird to translate "make sense" into Korean, but you can think of it as focusing on "reusability."

For example, apscheduler

The apscheduler is a package that manages the module about the schedule

In this package, apscheduler.events / apscheduler.job / apscheduler.Each module, such as schedulers, manages the event/job/scheduler.


2022-09-21 16:17

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.