Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9202247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:12:37+00:00 2026-06-17T23:12:37+00:00

I was playing around with argparse in python. I had something like below: group_gen.add_argument(‘–switch’,

  • 0

I was playing around with argparse in python. I had something like below:

group_gen.add_argument('--switch', nargs=2, metavar=('PARAM1', 'PARAM2'))

I then removed PARAM2 so I had:

group_gen.add_argument('--switch', nargs=2, metavar=('PARAM1', 'PARAM2'))

Then whenever argparse had to print help, I would get the following exception with stack trace

Traceback (most recent call last):
  File "./script.py", line 20, in <module>
    args = parser.parse_args()
  File "/usr/lib/python2.7/argparse.py", line 1688, in parse_args
    args, argv = self.parse_known_args(args, namespace)
  File "/usr/lib/python2.7/argparse.py", line 1727, in parse_known_args
    self.error(str(err))
  File "/usr/lib/python2.7/argparse.py", line 2346, in error
    self.print_usage(_sys.stderr)
  File "/usr/lib/python2.7/argparse.py", line 2308, in print_usage
    self._print_message(self.format_usage(), file)
  File "/usr/lib/python2.7/argparse.py", line 2264, in format_usage
    return formatter.format_help()
  File "/usr/lib/python2.7/argparse.py", line 279, in format_help
    help = self._root_section.format_help()
  File "/usr/lib/python2.7/argparse.py", line 209, in format_help
    func(*args)
  File "/usr/lib/python2.7/argparse.py", line 317, in _format_usage
    action_usage = format(optionals + positionals, groups)
  File "/usr/lib/python2.7/argparse.py", line 449, in _format_actions_usage
    args_string = self._format_args(action, default)
  File "/usr/lib/python2.7/argparse.py", line 587, in _format_args
    result = ' '.join(formats) % get_metavar(action.nargs)
TypeError: not enough arguments for format string

Why am I getting this error?

I was having trouble figuring out what was going on, then it dawned on me, with the command format string

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T23:12:38+00:00Added an answer on June 17, 2026 at 11:12 pm

    I think your question is typo’d badly, but try this:

    group_gen.add_argument('--switch', nargs=1, metavar=('PARAM1'))
    

    Is that what you’re trying to do?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While playing around with regexps in Scala I wrote something like this: scala> val
Playing around with Python - tkInter - Entry widget - when I use validatecommand
I'm playing around with Google Buzz API from Python, During the OAuth process when
Just playing around with interfaces and I have a question about something which I
Playing around in Instruments, I noticed something I don't understand. I create a couple
Playing around with MongoDB and NoRM in .NET. Thing that confused me - there
Just playing around with Wordpress / Contact Form 7 . Is it possible to
been playing around with ResolveClientUrl(~/Confirmation.aspx) and other methods.. I am tryin go get the
I playing around with the Twitter API for my BlackBerry application. Is there any
After playing around with haskell a bit I stumbled over this function: Prelude Data.Maclaurin>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.