
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Define Multiple Python Classes in a Single File
Python is not class-based exclusively - the basic unit of code decomposition in Python is the module. A module is a distinct thing that may have one or two dozen closely-related classes. Modules may as well contain functions along with classes. In Python there is rule of one module=one file.
In Python if you restrict yourself to one class per file (which in Python is not prohibited) you may end up with large number of small files - not easy to keep track.
So depending on the scenario and convenience one can have one or more classes per file in Python.
Advertisements