Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!feeds.phibee-telecom.net!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.019 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'subject:None': 0.09; 'subject:Why': 0.09; 'cc:addr:python-list': 0.11; 'assigns': 0.16; 'call?': 0.16; 'subject: \n ': 0.16; 'subject:argparse': 0.16; 'cc:addr:python.org': 0.22; 'skip': 0.24; '(or': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'option': 0.32; 'used,': 0.33; 'noticed': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'subject:?': 0.36; 'being': 0.38; 'confirmed': 0.38; 'list,': 0.38; 'rather': 0.38; 'default': 0.69 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=QB4EZPmKs83ho48yMcxgk2rFbwsOeslSz/ame0YxIPE=; b=j+SZXU5nWiarAalesHZA4FS7RSQYngDHdgpryNCcLkg7fJQDqCvesTP3gBfgkYsrtu EfDif83UY+ddMDHwCKRt1+54OwRCaNQszK0a5wzcg85T882zvdw2o1s40CK4ie3DIOkM EPxY9q3+g3aPiYuqnruTzankTReCJ7dJ5612SOriADI21sXs/hhSLjFpbhQDIwCp88vW cg07qHsgS87QpMSNS5RAOLnCcVnEpD81yk8XZl4x7qURQRVnwcNNfARlJME9rnNtVfD3 SWelq8EF532N3uCu0SWCMNCPvILNRNjCb0Wz4fEJq6lBcBjj+MXeLy/3Y4Tncq9LNITW Cv1A== MIME-Version: 1.0 X-Received: by 10.60.144.194 with SMTP id so2mr9464481oeb.65.1420815423502; Fri, 09 Jan 2015 06:57:03 -0800 (PST) In-Reply-To: References: Date: Fri, 9 Jan 2015 08:57:03 -0600 Subject: Re: Why does argparse return None instead of [] if an append action isn't used? From: Skip Montanaro To: Adam Funk Content-Type: text/plain; charset=UTF-8 Cc: Python 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: 8 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1420815432 news.xs4all.nl 2853 [2001:888:2000:d::a6]:53226 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:83444 > I noticed in use that if an option with the 'append' action isn't > used, argparse assigns None to it rather than an empty list, & > confirmed this interactively: I don't use argparse (or optparse), being a getopt Luddite myself, but can you set the default for an action in the add_argument call? Skip