Path: csiph.com!usenet.pasdenom.info!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed3.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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'argument': 0.05; 'defaults': 0.07; 'absent': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'jan': 0.12; '"default': 0.16; 'arguments:': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'subject:argparse': 0.16; 'subject:default': 0.16; 'subject:values': 0.16; 'supplied': 0.16; 'undocumented': 0.16; 'ignore': 0.16; 'wrote:': 0.18; 'command': 0.22; 'header:User- Agent:1': 0.23; 'interpret': 0.24; 'fine': 0.24; 'values': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'that.': 0.31; 'doc': 0.31; 'values.': 0.31; 'url:python': 0.33; 'sense': 0.34; 'could': 0.34; 'basic': 0.35; 'but': 0.35; 'there': 0.35; 'interaction': 0.36; 'url:org': 0.36; 'being': 0.38; 'actions': 0.38; 'url:library': 0.38; 'to:addr:python-list': 0.38; 'skip:- 10': 0.38; 'pm,': 0.38; 'expect': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'skip:n 30': 0.60; 'url:3': 0.61; 'received:173': 0.61; 'default': 0.69; 'behavior': 0.77; 'actions.': 0.84; 'florian': 0.84; 'received:fios.verizon.net': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: argparse action on default values Date: Wed, 08 Jan 2014 18:20:15 -0500 References: <7353849.WXZ0zEZ0QV@horus> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-173-75-254-207.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 In-Reply-To: <7353849.WXZ0zEZ0QV@horus> 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: 33 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1389223231 news.xs4all.nl 2917 [2001:888:2000:d::a6]:46431 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:63532 On 1/8/2014 1:20 PM, Florian Lindner wrote: > I use argparse from Python 3.3.3 with a custom action that normalizes > path arguments: > This works fine when there is actually a --config=path supplied. But > it's not being applied on default arguments. This behavior is how I interpret the doc. http://docs.python.org/3/library/argparse.html#the-add-argument-method "action - The basic type of action to be taken when this argument is encountered at the command line." "default - The value produced if the argument is absent from the command line." > Of course, I could use "default = norm_path('~/.foobar/config')" Do that. > but I expect that custom actions are applied to default values as well. See doc quote. > The store action works alike for default and supplied values. It would make no sense to ignore defaults. There may be some undocumented subtleties in the interaction of defaults and actions. -- Terry Jan Reedy