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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:45:22+00:00 2026-06-12T06:45:22+00:00

I have a package with a similar structure as scipy/numpy, where you have a

  • 0

I have a package with a similar structure as scipy/numpy, where you have a few main submodules, and each submodule contains functions from various files that have been flattened into the same namespace. Let’s say

package/
  sub1/
    __init__.py
    file1.py
    file2.py

And then sub1/__init__.py looks like this:

from .file1 import func1, func2
from .file2 import func3

The result is that I can do

import package.sub1
package.sub1.func1()

However, the problem is that the following does not work:

>>> import package.sub1
-- change things in file1.py --
>>> reload(package.sub1)

The function does not update. It works if I do import package.sub1.file1 instead, so there is something with flattening the namespace, that makes it lose the connection to the module. My main question is how I can still use the reload command, while still getting the benefits of being able to write sibling functions in separate files.

  • 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-06-12T06:45:23+00:00Added an answer on June 12, 2026 at 6:45 am

    Make the __init__.py reload the files it imports when it is imported:

    import file1
    import file2
    reload(file1)
    reload(file2)
    
    func1, func2 = file1.func1, file1.func2
    func3 = file2.func3
    

    That said, relying on reload() is generally a bad idea if you can avoid it.

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

Sidebar

Related Questions

I have a package with a few modules, each module has a class (or
I have two projects with similar starting splash and menu activities, but the package
I have one package contains many Stored Procedure for populating diffrent tables. This package
I have next package structure webService.ear -- dependency.jar -- some.class Can I remove some.class
I have strange problem. I have class which behaves similar dropdown list. package test.view;
I have a python package that needs to pull in settings from my project
Let's Say I Have This Class: package{ import flash.display.Sprite; public class Main extends Sprite{
I have set up an Oracle Package with a procedure similar to the code
I have a very simple SSIS package where I take data from a view
i'm coming into C++ from Java/AS3-land, and i'm used to the package-cum-folder structure for

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.