0

I wonder how good programmers get command line parameters in Python? What if there are a lot of parameters?

def main():
    type = None if len(sys.argv) == 1 else sys.argv[1]
    date = None if len(sys.argv) != 3 else sys.argv[2]
4
  • Did you try sys.argc? Commented Sep 17, 2013 at 7:10
  • Have you looked at the argparse module that comes with Python 2.7 onwards? Commented Sep 17, 2013 at 7:10
  • @Smac89 There isn't a sys.argc :) Commented Sep 17, 2013 at 7:11
  • 2
    You don't assign 40,000 command line arguments to 40,000 variables. There are things called lists. Commented Sep 17, 2013 at 7:12

1 Answer 1

7

Check out argparse, it's replacing optparse.

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.