0

I have one small python script called genData that contains a function genWork that takes 5 arguments. In another script, I do

from genData import genWork

and then call the function genWork(1, 2, 3, 4, 5). That worked just fine, and the other script runs as expected.

I then edited the function genWork in the genData file and it now takes 7 arguments. I keep the same import lines in the other script, and use the function as genWork(1, 2, 3, 4, 5, 6, 7). I get the error:

TypeError: genWork() takes exactly 5 arguments (7 given)

So, I am guessing somehow the genData script did not actually update? I tried deleting the .pyc file that got created, but I still get the same error.

3
  • 1
    Did you click save after you edited the file? Commented Jun 25, 2015 at 17:47
  • Did you also check if there is any sys.argv related comparison somewhere in the file? Commented Jun 25, 2015 at 17:54
  • @Bharadwaj hmm, no 'sys.argv' stuff going on, as the second script just calls the function with arguments inside it, not taking arguments from the command line. Commented Jun 25, 2015 at 18:01

2 Answers 2

1

You could also try removing .pyc files and running again ( assuming you saved your files). The files should have been updated automatically sometimes that doesn't work as expected.

I wanted to add this as a comment but I don't have enough reputation.

Sign up to request clarification or add additional context in comments.

Comments

0

Well I'm dumb, I figured out my problem. (Answering in case others have a similar problem.)

I had an old version of genData saved in a different directory. That directory was in my path but the one I was working in was NOT in my path. So, when I imported the genWork function from genData, it was importing that old version from the other directory.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.