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 8062189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:35:04+00:00 2026-06-05T10:35:04+00:00

I have several optional arguments and one of them needs to store multiple values

  • 0

I have several optional arguments and one of them needs to store multiple values – i.e. its type is neither string nor integer. Does argparse support optional arguments of other types?

For example, I would like this command:

>>> python example1 test_project --name try1 3

to be the equivalent of code like this:

args.name = {'try1', '3'}

Is this possible? Or will I be forced to use action='store_true' and then prompt the user for more information if he choose this option?

  • 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-05T10:35:07+00:00Added an answer on June 5, 2026 at 10:35 am

    I’m really having a hard time following your question. Is this what you want?

    import argparse
    
    parser=argparse.ArgumentParser()
    parser.add_argument('--name',nargs='*',action='store')
    
    print(parser.parse_args('--name try1 3'.split())) #Namespace(name=['try1', '3'])
    

    If it isn’t, perhaps you could try to be a little more clear with what you want to make argparse do, and what you’ve been able to do with it.

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

Sidebar

Related Questions

I have several annotations on a mapview. After selecting one of them (callout enabled)
I have a lot of optional fields in Mongoid, like: field :key, type: String
I have a controller with an Index method that has several optional parameters for
I have several cases where my string in strings.xml is quite long and has
I have several 2-dimentional arrays under a hdf5 file, how can I merge them
I have several thousands of files, some of them contain HTTP request and some
I have URLs like http://example.com/depict?smiles=CO&width=200&height=200 (and with several other optional arguments) My urls.py contains:
I have a Python function which takes several arguments. Some of these arguments could
I'm using Tapestry 4. I have several TextFields whose values get passed into Strings
I have a custom UserControl which contains several TextBoxes with Validators. One TextBox with

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.