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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:29:58+00:00 2026-05-14T23:29:58+00:00

scenario: a modular app that loads .py modules on the fly as it works.

  • 0

scenario: a modular app that loads .py modules on the fly as it works. programmer (me) wishes to edit the code of a module and then re-load it into the program without halting execution.

can this be done?

i have tried running import a second time on an updated module.py, but the changes are not picked up

  • 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-14T23:29:58+00:00Added an answer on May 14, 2026 at 11:29 pm

    While reload does reload a module, as the other answer mentions, you need quite a few precautions to make it work smoothly — and for some things you might believe would work easily, you’re in for quite a shock in terms of amount of work actually needed.

    If you ever use the form from module import afunction, then you’ve almost ensured reload won’t work: you must exclusively import modules, never functions, classes, etc, from inside modules, if you want to have any hope of reload doing something useful all all (otherwise you’d have to somehow chases all the bits and pieces imported here and there from the module, and rebind each and every one of them — eep;-). Note that I prefer following this rule anyway, whether I plan to do any reloading or not, but, with reload, it’s crucial.

    The difficult problem is: if you have, alive anywhere, instances of classes that existed in the previous version of the module, reload per se will do absolutely nothing to upgrade those instances. That problem is a truly hard one; one of the longest, hardest recipes in the Python Cookbook (2nd edition) is all about how to code your modules to support such “reload that actually upgrades existing instances”. This only matters if you program in OOP style, of course, but… any Python program complex enough to need “reload this plugin” functionality is very likely to have lots of OOP in it, so it’s hardly a minor issue.

    The docs for reload are pretty complete and do mention this issue, but give no hint how to solve it. This recipe by Michael Hudson, from the Python Cookbook online, is better, but it’s only the start of what we evolved into the printed (2nd edition) — recipe 20.15, the online version of that is here (incomplete unless you sign up for a free time-limited preview of O’Reilly’s commercial online books service).

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

Sidebar

Related Questions

Scenario: An MVC3 app that uses constructor injection to provide services for a given
Scenario: Most smartphones have a high resolution camera that generates photos that may range
Scenario: I start out in my app's main page. I navigate to sub-page A,
Scenario: I have several services that I want to be discovered by different clients.
Scenario: UserControl that has a read-only TextBox and a Button. TextBox.Text is modified and
Scenario- I have a method that returns an object retrieved from an NSMutableArray similar
Scenario 1 - everything works: var AwesomeObject = function() { var self = this;
Scenario: A stored procedure receives from code a DateTime with, let's say DateTime.Now value,
Scenario: You have an ASP.Net webpage that should display the next image in a
Scenario is that we send out thousands of emails through SMTP server. Content is

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.