Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: Is vars() the most useless Python built-in ever? Date: Wed, 2 Dec 2015 22:02:06 +1100 Lines: 20 Message-ID: References: <565cf141$0$1612$c3e8da3$5496439d@news.astraweb.com> <20151201084416.GA2700@beagle> <20151201213100.GA9665@beagle.localdomain> <20151202090954.GC9665@beagle.localdomain> <20151202094033.GA12749@beagle> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de /yCPtyqaQCtEffe4jEjaXgJfGWTVNAPD0DSig9ppCXcQ== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'received:209.85.223': 0.03; 'subject:Python': 0.05; 'encoded': 0.05; 'cc:addr:python- list': 0.09; 'callable.': 0.09; 'libraries.': 0.09; 'wed,': 0.15; 'argparse': 0.16; 'collects': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'received:209.85.223.173': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:ever': 0.16; 'subject:most': 0.16; 'wrote:': 0.16; 'library': 0.20; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'decorator': 0.22; 'function,': 0.22; 'dec': 0.23; 'slightly': 0.23; 'header:In-Reply-To:1': 0.24; 'module': 0.25; 'install': 0.25; 'message-id:@mail.gmail.com': 0.27; 'function': 0.28; 'developing': 0.28; 'asks': 0.29; 'idea,': 0.29; 'pointer.': 0.29; 'seemingly': 0.29; 'normally': 0.30; "i'd": 0.31; 'that,': 0.34; 'received:google.com': 0.35; 'could': 0.35; 'functions.': 0.35; 'but': 0.36; 'project': 0.36; 'lines': 0.36; 'received:209.85': 0.36; 'subject:?': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'turn': 0.37; 'thanks': 0.37; 'received:209': 0.38; 'does': 0.39; 'subject:the': 0.39; "didn't": 0.39; 'subject:-': 0.39; 'some': 0.40; 'total': 0.62; 'per': 0.62; 'is.': 0.63; 'here': 0.66; 'user,': 0.67; 'chrisa': 0.84; 'clize': 0.84; 'otten': 0.84; 'to:none': 0.91; 'cost:': 0.91 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:cc :content-type; bh=wb7L6ulN9CDbLKOhlnTiXXReLTEk/SNvJEzOy010GyQ=; b=GHMTpf9GKvkeyqSqLOogBaTk3TZsYGUPn2l14E9Oi5oWK9GxOG9ClEFI/IH2FzaRCz WC8kI5kCiYGyBdmI2FVC+FTEm1ylrEQPyBwqMjvgnpeqnC57o/qNdQEqV1sl2KLR146t Bi6eKHcCf6wq2O45J3+2Zn4s5mZbl6f2zpgutI8G3/vs0ARoESH9Mb57M71lekkSaEX3 1FxC8LsXHWsdfBYPSf1dJhKXecyzUhC9+sDNCX4ZVydZ2FSYbucHI70X8Jq/wIMtjXGk rGdzFssNjWiUfRtbqPlyMYS98j2ANi81s5WEopZWiNT4rY1MxrzfRZrdmzYN51sbuYxa UxPQ== X-Received: by 10.107.10.233 with SMTP id 102mr2920695iok.31.1449054127023; Wed, 02 Dec 2015 03:02:07 -0800 (PST) In-Reply-To: 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: , Xref: csiph.com comp.lang.python:99868 On Wed, Dec 2, 2015 at 9:48 PM, Peter Otten <__peter__@web.de> wrote: >> I try to do as much as I can with standard library tools. As a user, I >> find it somewhat off-putting when a tiny project asks you to install any >> number of seemingly unrelated libraries. But clize does look like a good >> idea, thanks for the pointer. > > Same here ;) I found out about clize by developing my own module that did the same job - and then found that, by compromising VERY slightly on some specifics, I could turn my usage directly to clize :) One thing I didn't want to compromise on was the simplicity of setup that I'd had - just slap a decorator onto every function that you want to make into a callable. So I made my own decorator that collects up the functions. Total cost: Three lines at the top, two at the bottom (if name is main, clize.run), and one line per function, plus the encoded docstring. That's a LOT cheaper than argparse normally is. ChrisA