Reputation: 2837
I wrote a module in python (using pydev
). Most of my code is written in the 'main'
. In the code, I read from a file. I wrote:
inputFile = 'training_data.txt'
Later, I tried getting the name of the inputFile as a parameter:
inputFile = str(sys.argv[0])
When I changed to that, I started getting the following error lots of times:
pydev debugger: Unable to find module to reload: "boolean_conj_predictor".
**boolean_conj_predictor
is the name of the module.
Upvotes: 0
Views: 1987
Reputation: 77053
str(sys.argv[0])
will be the name of the file you are running. Instead, try to access the next element, i.e., do inputFile = sys.argv[1]
.
You can observe this behaviour with a simple print statement, within your code, if you put a statement print sys.argv
and then run your file like python test.py filename.txt
, you will see the output array as ['test.py', 'filename.txt']
Upvotes: 1