0

This is giving a wierd error:

if __name__ == "__main__":
    import argparse
    import json

    from evaluation import cross_validation
    from predictor import PhraseSentimentPredictor

    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument("filename")
    config = parser.parse_args()
    config = json.load(open(config.filename))

Error:

**usage: generate_kaggle_submission.py [-h] filename
    generate_kaggle_submission.py: error: too few arguments**

Please help

1
  • Can you show how you are running the program? Commented Dec 21, 2014 at 15:08

1 Answer 1

2

Make sure you invoke the python program with the filename argument.


If you want to make the filename argument optional, specify nargs with ? or *:

parser.add_argument("filename", nargs='?')
# OR with default
parser.add_argument("filename", nargs='?', default='default_filename')

See nargs - argparse - Python documentation for other available options.

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

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.