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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:12:04+00:00 2026-05-25T20:12:04+00:00

Is it possible to change python source file while running an application and have

  • 0

Is it possible to change python source file while running an application and have this changes reflected immediately in the application?

Let say I have a foo.py file with a class Foo. In other module I’m calling functions on the Foo on user action. Now, I would like to change source of the Foo without restarting the application and on next user input see the results of the new code.

Would that be possible?

  • 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-25T20:12:05+00:00Added an answer on May 25, 2026 at 8:12 pm

    Yes, but it ill advised — code which changes itself (although necessary in some cases) is notoriously hard to debug. You’re looking for the reload method. The way that you would get it to work would be to modify the source file and then call reload on the module, then repeat.

    You do have the option of re-assigning and modifying the code within the application itself — something which does not risk race conditions and it will also allow for a more consistent and testable environment. For an example, I would recomment Ignacio Vazquez-Abrams‘s answer.


    Have you tried to see what you could manage by merely changing a state (an external config file, database entry, etc)

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

Sidebar

Related Questions

I have Python code to call a REST service that is something like this:
I have a financial pricing application written in Python 2.4.4 which runs as an
Is it possible to change the Windows command prompt working directory via Python script?
This is a source code for Quicksort in Python I found on Wikipedia. def
Is it possible to change background color of the Python Shell from white to
Possible Duplicate: Python: Behaviour of increment and decrement operators Hi, I've tried this. ++num
Suppose I have below python file structure: \function_group |-__init__.py |-sub_function1 |----|__init__.py |----|sub_sub_func1.py |----|sub_sub_func2.py |----|sub_sub_func3.py
Possible Duplicate: Paste (Python) Web Server - Autoreload Problem I have a pylons app
Is it possible in python to change what is printed for classes. I know
I know this is possible, I'm a newbie on Python. Looked at nose. But

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.