Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.datemas.de!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2.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.039 X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; 'sys': 0.07; 'arguments': 0.09; 'namespace': 0.09; 'subject:command': 0.09; 'python': 0.11; "'bar']": 0.16; 'henry': 0.16; 'roy': 0.16; 'wrote:': 0.18; 'command': 0.22; 'import': 0.22; 'print': 0.22; 'header:User- Agent:1': 0.23; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'there': 0.35; 'i.e.': 0.36; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'mentioned': 0.61; 'simple': 0.61; "you're": 0.61; 'determine': 0.67; 'received:74.208': 0.68; 'smith': 0.68; 'article': 0.77; 'received:74.208.4.194': 0.84 Date: Wed, 15 May 2013 08:51:30 -0400 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Determine actually given command line arguments References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:J8zyt5zdtUd1+nzPy6TAOxn1rjSklnT0fEW8AofhA88 ktVH0iTCLpmREkQ4gg+UuVN6BvkebGUO5BBSBwu5VLojfEIUlI r/fQ6Dj/fWavh2tzdm1FkQW+ne+OEodEhHKgv7GM5utqCwuuBa akSNjU+Jnx33s3IQH8BJd7Jet81PBePsfgULMHSMS/2SYCz3Dc KfyLf4RUUqh0rHil5LgSvwszkwtHp50w+M5e5j1a5GRoIyxnZg iTNEchqaj+Wp3SGtmIpgSmAwddbLnrebpouxlpdpcLATvKVy+2 2dY/J2snqtHFpV09zA9pX5BqKlYLROeoun+RhKHEDX2MaBDDQ= = 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: 24 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1368622312 news.xs4all.nl 15979 [2001:888:2000:d::a6]:51920 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:45338 On 05/15/2013 08:24 AM, Roy Smith wrote: > In article , > Henry Leyh wrote: > >> Is there a simple way to determine which >> command line arguments were actually given on the commandline, i.e. does >> argparse.ArgumentParser() know which of its namespace members were >> actually hit during parse_args(). > > I think what you're looking for is sys.argv: > > $ cat argv.py > import sys > print sys.argv > > $ python argv.py foo bar > ['argv.py', 'foo', 'bar'] > Colin & Roy: The OP mentioned sys.argv in his original query. -- DaveA