Changing the module not taking effect in calling module

Discussion in 'Python' started by Gopal, Sep 27, 2005.

  1. Gopal

    Gopal Guest

    Hi,

    I've a module report.py having a set of funtions to open/close/write
    data to a log file. I invoke these functions from another module
    script.py.

    Whenever I'm changing something in report.py, I'm running the file
    (however, it has not effect). After that I'm running script.py again.
    However, the output is not taking effect.

    If I shut the IDLE interpreter and all the other files and then reopen
    again; and then run script.py, the output is taking effect.

    Is there any way to improve it? I'm new to Python.

    -Gopal.
     
    Gopal, Sep 27, 2005
    #1
    1. Advertising

  2. Gopal

    Juho Schultz Guest

    Gopal wrote:
    > Hi,
    >
    > I've a module report.py having a set of funtions to open/close/write
    > data to a log file. I invoke these functions from another module
    > script.py.
    >
    > Whenever I'm changing something in report.py, I'm running the file
    > (however, it has not effect). After that I'm running script.py again.
    > However, the output is not taking effect.
    >
    > If I shut the IDLE interpreter and all the other files and then reopen
    > again; and then run script.py, the output is taking effect.
    >
    > Is there any way to improve it? I'm new to Python.
    >
    > -Gopal.
    >


    you could try "reload(module)" instead of "import module" or running the file.
     
    Juho Schultz, Sep 27, 2005
    #2
    1. Advertising

  3. Gopal wrote:

    > I've a module report.py having a set of funtions to open/close/write
    > data to a log file. I invoke these functions from another module
    > script.py.
    >
    > Whenever I'm changing something in report.py, I'm running the file
    > (however, it has not effect). After that I'm running script.py again.
    > However, the output is not taking effect.
    >
    > If I shut the IDLE interpreter and all the other files and then reopen
    > again; and then run script.py, the output is taking effect.
    >
    > Is there any way to improve it? I'm new to Python.


    If I understand you correctly, you are importing your module report in
    script.py. If so, you need reload.

    When in IDLE, you have a python process running, in which you execute
    your program. The first time you run script.py after starting IDLE, your
    module report is imported from file. The next time you run script.py,
    there is already a module named report in memory. Then the corresponding
    file will not be executed again. Instead, the one in memory will be used.

    What I do when I am developing a module for a program is that I both
    import and reload the module in my main file. Once I think I am done
    developing, I remove the reload statement. So, in your script.py, I
    would write:

    import report
    reload(report)

    HTH
    /MiO
     
    Mikael Olofsson, Sep 27, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ryan McLean

    Problem with .aspx chenges taking effect

    Ryan McLean, Nov 18, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    326
    Ryan McLean
    Nov 26, 2003
  2. tshad
    Replies:
    3
    Views:
    1,258
    Patrice
    Mar 4, 2008
  3. Just4U

    Session.LCID changing has no effect

    Just4U, Aug 27, 2007, in forum: ASP General
    Replies:
    0
    Views:
    234
    Just4U
    Aug 27, 2007
  4. Jim Cain
    Replies:
    1
    Views:
    218
    Yukihiro Matsumoto
    Jul 18, 2003
  5. Panceisto
    Replies:
    2
    Views:
    241
    Mark Hammond
    Jul 2, 2012
Loading...

Share This Page