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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:36:18+00:00 2026-06-17T06:36:18+00:00

I have a Python Module test, I want to edit test and run some

  • 0

I have a Python Module test, I want to edit test and run some functions in test at the interpreter. Will Python automatically see the differences in the functions that I edit in test without reimporting? What is the appropriate word for this action?

  1. What are the best practices for reimporting/reloading/redefining?
  2. How can this be done efficiently? (It seems inefficient to highlight text with a mouse and then copy and paste).

EDIT Nothing mentioned so far is working so I will post a few more details:

A class is in my module, called Test. So I used the statement from test import Test. Now when I try the command reload(test) the interpreter tells me reload is undefined. If I do import imp then imp.reload(test) the interpreter tells me that test is undefined. What is going wrong here?

  • 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-17T06:36:19+00:00Added an answer on June 17, 2026 at 6:36 am

    I suspect you’re using Python 3, and all of the answerers are assuming you’re using Python 2.

    In Python 3, reload was moved from builtins to imp.

    So, the answer is:

    imp.reload(test)
    

    For future reference, if you’re using Python 3, it’s almost always worth mentioning it, unless you know for a fact that it’s not relevant, because many of the old-timers (read: the people you want answer from) will assume 2.7.

    Meanwhile, back to your main question:

    What are the best practices for reimporting/reloading/redefining?

    For simple cases, reload() or imp.reload() are exactly what you want. (For super-simple cases, there’s nothing wrong with copy and paste…)

    But it’s very easy to confuse yourself when you have, e.g., some object bar of class foo.Bar and then reload foo. It also doesn’t play too well with from foo import *, which is often handy for interactive sessions.

    If you can start up a new interpreter session and import the module, that’s much cleaner. If you need a bunch of objects created to start playing with the module, you can temporarily add them as globals to the module, or create a wrapper module that defines them. Some IDEs can wrap all of this up so just hitting some accelerator key sequence causes it to restart the interpreter and rerun your import and all your setup stuff.

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

Sidebar

Related Questions

I have a fairly complex system that I want to test using python. My
I have two test cases (two different files) that I want to run together
I have a python module that imports a module generated with swig. When I
I have a python module that I've been using over the years to process
I have created a simple Python module and want to distribute it with pip.
I have a python logger set up, using python's logging module. I want to
I have a simple Python script that uses the socket module to send a
I have an application that reads test scripts in python and sends them across
I'm trying to test some python code that uses urllib2 and lxml. I've seen
I want to have in my application a common logging module that logs to

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.