Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!feeder.erje.net!1.eu.feeder.erje.net!bcyclone01.am1.xlned.com!bcyclone01.am1.xlned.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'output': 0.05; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'main()': 0.09; 'message- id:@stoneleaf.us': 0.09; 'snippet': 0.09; 'url:github': 0.09; '~ethan~': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'def': 0.12; 'main():': 0.16; 'skip:{ 30': 0.16; 'subject: \n ': 0.16; 'subject:parser': 0.16; 'url:py': 0.16; 'wrote:': 0.18; 'file,': 0.19; 'import': 0.22; 'separate': 0.22; 'cc:addr:python.org': 0.22; 'header:User-Agent:1': 0.23; 'cc:2**0': 0.24; 'logging': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'subject:that': 0.31; 'run': 0.32; 'text': 0.33; 'subject:from': 0.34; 'charset:us-ascii': 0.36; 'level': 0.37; 'skip:- 60': 0.39; 'received:173': 0.61; 'content- disposition:inline': 0.62; 'name': 0.63; 'to:addr:gmail.com': 0.65; 'sample': 0.67; 'subject:your': 0.76 Date: Mon, 27 Apr 2015 22:28:57 -0700 From: Ethan Furman To: Chris Angelico Cc: "python-list@python.org" Subject: Re: Clize 3.0b1: An argument parser that draws a CLI from your function sigature Mail-Followup-To: Chris Angelico , "python-list@python.org" References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 66 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1430198945 news.xs4all.nl 2894 [2001:888:2000:d::a6]:48989 X-Complaints-To: abuse@xs4all.nl X-Received-Bytes: 4721 X-Received-Body-CRC: 2051377422 Xref: csiph.com comp.lang.python:89478 On 04/28, Chris Angelico wrote: > That's a lot of separate pieces. Here's the docstringargs equivalent: > > https://github.com/Rosuav/snippets/blob/dsa/snippets.py Just for grins, here's that using Scription: -- 8< -------------------------------------------------------------------- """Store and retrieve snippets of text""" from scription import * import logging # Set the log output file, and the log level logging.basicConfig(filename="snippets.log", level=logging.DEBUG) data = {} @Script() def main(): print('Result: {!r}'.format(script_command())) @Command( name=('the name of the snippet', ), snippet=('the snippet text', ), ) def put(name, snippet): "Store a snippet with an associated name." logging.info("Storing({!r}, {!r})".format(name, snippet)) data[name] = snippet return name, snippet @Command( name=('the name of the snippet', ), ) def get(name): "Retrieve the snippet with a given name." logging.error("Retrieving({!r})".format(name)) return data.get(name) Main() -- 8< -------------------------------------------------------------------- and a sample run with nothing selected: -- 8< -------------------------------------------------------------------- $ python snippet Store and retrieve snippets of text snippet get NAME Retrieve the snippet with a given name. NAME the name of the snippet snippet put NAME SNIPPET Store a snippet with an associated name. NAME the name of the snippet SNIPPET the snippet text -- 8< -------------------------------------------------------------------- -- ~Ethan~