Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #34299 > unrolled thread

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

Started byBruno Dupuis <python.ml.bruno.dupuis@lisael.org>
First post2012-12-05 18:42 +0100
Last post2012-12-05 18:42 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: How does one make argparse print usage when no options are provided on the command line? Bruno Dupuis <python.ml.bruno.dupuis@lisael.org> - 2012-12-05 18:42 +0100

#34299 — Re: How does one make argparse print usage when no options are provided on the command line?

FromBruno Dupuis <python.ml.bruno.dupuis@lisael.org>
Date2012-12-05 18:42 +0100
SubjectRe: How does one make argparse print usage when no options are provided on the command line?
Message-ID<mailman.505.1354729351.29569.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web