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 6772775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:35:19+00:00 2026-05-26T15:35:19+00:00

I have a growing number of scripts that make up a program I am

  • 0

I have a growing number of scripts that make up a program I am writing and decided it was time to clean up my source tree and package them up correctly. I’m sure this is a simple question but I can’t find out how to do it.

If I have a group of modules, that fit together, but one should be a top-level module and the others should be prefixed by the module name but actually go into lower level packages, how can I do it.

For example say I wanted to be able to import mystuff, and get all mystuff. but I also should be able to import mystuff.test.test1. I thought I would create a source tree like this,

myprogram/
    mystuff.py
    mystuff/
        __init__.py
        tests/
            __init__.py
            test1.py
            test2.py
            ...

But in this case, it seems mystuff/ always takes precedence over mystuff.py, so import mystuff does nothing (as long as mystuff/‘s __init__.py is empty).

What would be the correct approach to get the desired behaviour? Or is this not possible and must I move mystuff.py into mystuff/ and have to access it as mystuff.mystuff ( seem’s like unnecessary repetion).

Sorry, if I’ve just missed something obvious. I assume this must be documented somewhere, but I can’t seem to find where somewhere is.

Update. While I believe Ignacio’s method is the correct one, I don’t really like it! If I have multiple files open in my editor and they’re all called __init__.py things could get messy. So, I have decided to leave my structure as it is, and link mystuff.py to mystuff/__init__.py. If anyone has any opinions on why I shouldn’t be doing this, I’d like to hear them.

Actually in the end, I am linking the other way around, since I couldn’t find a way to make distutils dereference symlinks when creating a tar.gz, and I ended up with broken links in my output. This way has the same effect and keeps it happy.

  • 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-26T15:35:19+00:00Added an answer on May 26, 2026 at 3:35 pm

    Everything in mystuff.py should be placed into mystuff/__init__.py instead.

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

Sidebar

Related Questions

I have a master-workers architecture where the number of workers is growing on a
A have a database on MS-SQL Server 2008 that is growing a lot, year
I have an application that has several objects (about 50 so far, but growing).
I have a ms sql server database with a growing number of stored procedures
I have a small test program that creates millions of files (for testing purposes)
I am writing a scriptable game engine, for which I have a large number
I have about 20 classes for different messages and this number are growing. Each
Possible Duplicate: C dynamically growing array I have a program and I need to
I have noticed more and more a growing number of resources for developing applications
I am growing the number of tables I have and I am sometimes curious

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.