Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python,': 0.02; 'arguments': 0.09; 'subject:question': 0.10; 'python': 0.11; 'andy': 0.16; 'invoked.': 0.16; 'selected.': 0.16; 'subject:python': 0.16; 'command': 0.22; '(in': 0.22; 'shell': 0.22; 'creating': 0.23; 'unix/linux': 0.24; 'cheers,': 0.24; 'options': 0.25; 'script': 0.25; 'programming.': 0.30; 'restrict': 0.30; 'message-id:@mail.gmail.com': 0.30; 'figure': 0.32; 'option': 0.32; 'subject: (': 0.35; "can't": 0.35; 'received:google.com': 0.35; 'add': 0.35; 'there': 0.35; 'should': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'read': 0.60; 'new': 0.61 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=0d9UjiuUk0gDpws+Jcee4WWPPs79MydSFc2vFj63axI=; b=cgBTB18OCjOJ4eMqSYwgPklDkROvmUMePMuYM4bcdjFkH1y8dVxpu7aeV0YM4juLt7 LquOpSnkpj9iu+4GaYkZfTa19B6kpIaPWaOOD7+XVY3CrfrRcf9SQMQrlnjJkBCinq6L 5KE4bFpSgGFQXj3t/Gs87muDx+bZc50XJePpkqEVH9EiDTfwRMh0rOaWMsMwuQSNdcFl EbCU3GAwN3zHMZ7tERyB4+0a97pehWmU0ywNoZX5SIYz5AhfgcbmbuEjqCmDmy14o7NY TeGNr5ciqmkhWzzC4IHGhW6ABuGTrJt27GAkUInsUVk8ujntliKNOeOX3FXq9A36ov8L BEMA== X-Received: by 10.66.186.12 with SMTP id fg12mr3492172pac.178.1377533838814; Mon, 26 Aug 2013 09:17:18 -0700 (PDT) MIME-Version: 1.0 From: Andy Kannberg Date: Mon, 26 Aug 2013 18:16:58 +0200 Subject: optparse question (python 2.6) To: python-list@python.org Content-Type: multipart/alternative; boundary=047d7bf0e42620f60604e4dc1705 X-Mailman-Approved-At: Mon, 26 Aug 2013 18:24:05 +0200 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 40 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1377534246 news.xs4all.nl 16011 [2001:888:2000:d::a6]:46805 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:53009 --047d7bf0e42620f60604e4dc1705 Content-Type: text/plain; charset=ISO-8859-1 Hi python-guru's, I am new to Python, coming from a long history of Unix/linux shell programming. I am creating a Python script (In Python 2.6) which should be able to read command line options and arguments. So far, I figured out how to do that with optparse. I can add options (and arguments ) . There are about 7 options that can be selected. However, I can't seem to figure out how to force that only one option is allowed when the script is invoked. In other words: How to restrict the script to accept only one of the available options ? cheers, Andy --047d7bf0e42620f60604e4dc1705 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Hi python-guru's,

I am new to Pytho= n, coming from a long history of Unix/linux shell programming.
I = am creating a Python script (In Python 2.6) =A0which should be able to read= command line options and arguments.=A0
So far, I figured out how to do that with optparse. I can add options = (and arguments ) .
There are about 7 options that can be selected= .=A0

However, I can't seem to figure out how t= o force that only one option is allowed when the script is invoked. In othe= r words: How to restrict the script to accept only one of the available opt= ions ?

cheers,
Andy


--047d7bf0e42620f60604e4dc1705--