Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: How does one make argparse print usage when no options areprovided on the command line?

Reply
Thread Tools

Re: How does one make argparse print usage when no options areprovided on the command line?

 
 
Bruno Dupuis
Guest
Posts: n/a
 
      12-05-2012
On Wed, Dec 05, 2012 at 08:48:30AM -0800, rh wrote:
> I have argparse working with one exception. I wanted the program to print out
> usage when no command line options are given. But I only came across
> other examples where people didn't use argparse but instead printed out
> a separate usage statement. So they used argparse for everything but the
> case where no command line args are given.
>


this is quite raw, but i'd add

import sys
if len(sys.argv) == 1:
sys.argv.append('-h')

before I call parser.parse_args()

Should work


--
Bruno Dupuis
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How does one make argparse print usage when no options areprovided on the command line? rh Python 0 12-06-2012 06:42 PM
Re: How does one make argparse print usage when no options areprovided on the command line? Terry Reedy Python 0 12-06-2012 05:06 AM
Re: How does one make argparse print usage when no options areprovided on the command line? rh Python 0 12-06-2012 12:48 AM
Re: How does one make argparse print usage when no options areprovided on the command line? rh Python 0 12-05-2012 08:52 PM
Re: How does one make argparse print usage when no options areprovided on the command line? Ian Kelly Python 0 12-05-2012 06:31 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57