Skip to main content
edited title
Link
nbro
  • 16.1k
  • 34
  • 122
  • 219

argparse option for passing How can I pass a list as optiona command-line argument with argparse?

deleted 2 characters in body
Source Link
Wasi Ahmad
  • 38.1k
  • 34
  • 129
  • 169

I am trying to pass a list as an argument to a command line program. Is there an argparse option to pass a list as option?

 parser.add_argument('-l', '--list', type=list, action='store', dest='list', help='<Required> Set flag', required=True) 

Script is called like below

python test.py -l "265340 268738 270774 270817" 

I am trying to pass a list as an argument to a command line program. Is there an argparse option to pass a list as option?

 parser.add_argument('-l', '--list', type=list, action='store', dest='list', help='<Required> Set flag', required=True) 

Script is called like below

python test.py -l "265340 268738 270774 270817" 

I am trying to pass a list as an argument to a command line program. Is there an argparse option to pass a list as option?

parser.add_argument('-l', '--list', type=list, action='store', dest='list', help='<Required> Set flag', required=True) 

Script is called like below

python test.py -l "265340 268738 270774 270817" 
formatting
Source Link
Martin Thoma
  • 138.6k
  • 174
  • 687
  • 1.1k

I am trying to pass a list as an argument.. to a command line program. Is there an argparseargparse option to pass a list as option?

 parser.add_argument('-l', '--list', type=list, action='store', dest='list', help='<Required> Set flag', required=True) 

Script is called like below

python test.py -l "265340 268738 270774 270817" 

I am trying to pass a list as an argument... Is there an argparse option to pass a list as option?

 parser.add_argument('-l','--list',type=list,action='store',dest='list',help='<Required> Set flag',required=True) 

Script is called like below

python test.py -l "265340 268738 270774 270817" 

I am trying to pass a list as an argument to a command line program. Is there an argparse option to pass a list as option?

 parser.add_argument('-l', '--list', type=list, action='store', dest='list', help='<Required> Set flag', required=True) 

Script is called like below

python test.py -l "265340 268738 270774 270817" 
added argparse tag, minor edit
Source Link
nalply
  • 29.2k
  • 15
  • 84
  • 105
Loading
Source Link
carte blanche
  • 11.6k
  • 16
  • 50
  • 67
Loading