Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4544016
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T15:36:44+00:00 2026-05-21T15:36:44+00:00

My module is all in one big file that is getting hard to maintain.

  • 0

My module is all in one big file that is getting hard to maintain. What is the standard way of breaking things up?

I have one module in a file my_module.py, which I import like this:

import my_module

“my_module” will soon be a thousand lines, which is pushing the limits of my ability to keep everything straight. I was thinking of adding files my_module_base.py, my_module_blah.py, etc. And then, replacing my_module.py with

from my_module_base import *
from my_module_blah import *
# etc.

Then, the user code does not need to change:

import my_module  # still works...

Is this the standard pattern?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T15:36:45+00:00Added an answer on May 21, 2026 at 3:36 pm

    It depends on what your module is doing actually. Usually it is always a good idea to make your module a directory with an ‘__init__.py' file inside. So you would first transform your your_module.py to something like your_module/__init__.py.

    After that you continue according to your business logic. Here some examples:

    • do you have utility functions which are not directly used by the modules API put them in some file called utils.py

    • do you have some classes dealing with the database or representing your database models put them in models.py

    • do you have some internal configuration it might make sense to put it into some extra file called settings.py or config.py

    These are just examples (a little bit stolen from the Django approach of reusable apps ^^). As said, it depends a lot what your module does. If it is still too big afterwards it also makes sense to create submodules (as subdirectories with their own __init__.py).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have all the forms in one folder and all the code modules in
Python's subprocess module by default passes all open file descriptors to any child processes
We currently have a big Maven 2 project that is rather a collection of
I'm building a data seeder module that looks for all models using introspection and
I can't seem to get the wsgiref module to work at all under Python
I'd like to create several modules that will be used in nearly all scripts
I have a bunch of Python modules in a directory, all being a derivate
I am actually developing and application that has around 15 modules, all of them
Is there any python module to convert PDF files into text? I tried one
I have a really large file I'm trying to open with mmap and its

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.