Python class can't be updated after being compiled
Question: I just started with python a couple of days ago, coming from a C++ background.
When I write a class, call it by a script, and afterwards update the interface
of the class, I get some behaviour I find very unintuitive.

Once successfully compiled, the class seems to be not changeable anymore. Here
an example:

testModule.py:

    
    
    class testClass:
        def __init__(self,_A):
            self.First=_A
    
        def Method(self, X, Y):
            print X
    

testScript.py:

    
    
    import testModule
    
    tm=testModuleB.testClass(10)
    tm.Method(3, 4)
    

Execution gives me

    
    
    3
    

Now I change the argument list of `Method`:

    
    
    def Method(self, X):
    

, I delete the testModule.pyc and in my script I call

    
    
    tm.Method(3)
    

As result, I get

    
    
    TypeError: Method() takes exactly 3 arguments (2 given)
    

What am I doing wrong? Why does the script not use the updated version of the
class? I use the Canopy editor but I saw this behaviour also with the
python.exe interpreter.

And apologies, if something similar was asked before. I did not find a
question related to this one.


Answer: `testModule` is already loaded in your interpreter. Deleting the `pyc` file
won't change anything. You will need to do `reload(testModule)`, or even
better restart the interpreter.

