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

  • SEARCH
  • Home
  • 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 1056733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:45:33+00:00 2026-05-16T17:45:33+00:00

I have a package mypack with modules mod_a and mod_b in it. I intend

  • 0

I have a package mypack with modules mod_a and mod_b in it. I intend the package itself and mod_a to be imported freely:

import mypack
import mypack.mod_a

However, I’d like to keep mod_b for the exclusive use of mypack. That’s because it exists merely to organize the latter’s internal code.

My first question is, is it an accepted practice in Python programming to have ‘private’ modules like this?

If yes, my second question is, what is the best way to convey this intention to the client? Do I prefix the name with an underscore (i.e. _mod_b)? Or would it be a good idea to declare a sub-package private and place all such modules there?

  • 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-16T17:45:33+00:00Added an answer on May 16, 2026 at 5:45 pm

    The solution I’ve settled on is to create a sub-package ‘private’ and place all the modules I wish to hide in there. This way they stay stowed away, leaving mypack‘s module list cleaner and easier to parse.

    To me, this doesn’t look unpythonic either.

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

Sidebar

Related Questions

I have a package structured like this: a/a1/a1.py a/a2/a2.py a/a3/a3.py In a3.py, I imported
I have a package of plug-in style modules. It looks like this: /Plugins /Plugins/__init__.py
I have a package like this package/ __init__.py subpackage1/ __init__.py moduleA.py moduleB.py moduleC.py moduleD.py
I have a package with logic classes(like CheckAuthenticationDataLogic.java, GetVocabulariesLogic.java). And another class - ApiService.java
I have a package with a few modules, each module has a class (or
I have written a simple package program: //A simple package package MyPack class Balance
i have a package of classes compiled as jar file. how to import the
Say I have a package mylibrary. I want to make mylibrary.config available for import,
I have a package structure like com/tcs/incubation/sml/crawler/mediasources/twitterriver . I have a txt file which
I'm trying to set cookies with Go's net/http package. I have: package main import

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.