Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: Spot the bug: getoptquestion.py Date: Thu, 7 Jul 2016 22:12:37 +1000 Lines: 25 Message-ID: References: <577a4766$0$5839$e4fe514c@news.xs4all.nl> <577e3d66$0$5816$e4fe514c@news.xs4all.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de y9MLtGu4nxulgLhW5wZg9QObAMXLWRFhdKmrrwNjLH6g== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.009 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'subject:bug': 0.05; 'dependency': 0.07; 'wrapper': 0.07; 'cc:addr:python-list': 0.09; '"if': 0.09; 'yeah,': 0.09; 'thu,': 0.15; '(sorry,': 0.16; '2016': 0.16; 'argparse': 0.16; 'background,': 0.16; 'boilerplate,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'input.': 0.16; 'personally,': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'much!': 0.18; ';-)': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'third-party': 0.23; 'header:In-Reply-To:1': 0.24; 'command': 0.26; 'message- id:@mail.gmail.com': 0.27; 'looks': 0.29; 'docstrings': 0.29; "i'm": 0.30; 'that.': 0.30; 'minimal': 0.30; 'received:google.com': 0.35; 'improving': 0.35; 'something': 0.35; 'but': 0.36; 'too': 0.36; 'should': 0.36; 'tool': 0.36; 'basic': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'thanks': 0.37; 'subject:the': 0.39; 'still': 0.40; 'space': 0.40; 'your': 0.60; 'different': 0.63; 'worth': 0.67; 'risk': 0.68; 'jul': 0.72; 'introduce': 0.79; '*really*': 0.84; 'chrisa': 0.84; 'oscar': 0.84; 'to:none': 0.91; 'hassle': 0.91; 'subject:skip:g 10': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:cc; bh=Sa7d9zTrMfoJNVsjSVxCXgmZ6+WSQFzTJyGx1oPu+5s=; b=uQjGYrNCpmI3+gTAD42wiZrHl703jSqcduhMa8dhW4gduDXrVDiesArZADWF3+s3DQ PmTseYSZmWtijGDJbnmBlHdvubgH5mlkmyeoaZ5OKQZFwgATeOalssXYdfYnv37Vp8vR 1myTKyT/AbntmU40UD87fZJPOw1EKF66QUQ0FKeRoKjKTgMV+IUMeE6YTlM+HqlIJHqy ulBRyqlUhe/dFKK4Fn2lKuhgF2eP+FaiSFpHOKBYuGesSJf/y+cpzQo4I92GeHMhFoKD +4Pk0VXG9UHU/Bj/PsP3zypSaOK1ekwYwuMsIEbWRutgdCJmzlIGdERDrQPB89kxeIYp jMrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:cc; bh=Sa7d9zTrMfoJNVsjSVxCXgmZ6+WSQFzTJyGx1oPu+5s=; b=h1Z+/puH3n5j0DQpr7pnJODKz9/mexPpFh4Y0rA00ur9l2jQ5tqRVrrUcegYP8/pk/ K1SRxb3xZpd1XwB5h+xtVeFlpoZfMEG/tbFg6xo37FZW3GQEEIPbq32GP6IPNhoYmeLN hoI/vipsdnXt/Mt2nbKTa57cGLB13rQtUQ80/0ThgManmNZ5F8oRSjOtXLdQpNSwVqI7 I3dnhQBVcpyPh9sq1EIktl4Ahdcns+9B9LiMvlOmQ+pHFThu5rXAtz2uAicdfSUuqAXO pw/IvF+scbJO6zGR0/rZzGYQLXXgqUTfdtf2pTpYasG6OBqYVuw9HnIqAEIAmOEzeDRH G0lw== X-Gm-Message-State: ALyK8tLFNukRsrRrLzuzTlqDRrzxqto3WhykZzqfmyLBXnVyYTOX5RbA/EQTEHXXupYcvu/o5kq2ZPhN+b/vrQ== X-Received: by 10.28.144.80 with SMTP id s77mr27116193wmd.41.1467893563452; Thu, 07 Jul 2016 05:12:43 -0700 (PDT) In-Reply-To: <577e3d66$0$5816$e4fe514c@news.xs4all.nl> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: <577a4766$0$5839$e4fe514c@news.xs4all.nl> <577e3d66$0$5816$e4fe514c@news.xs4all.nl> Xref: csiph.com comp.lang.python:111185 On Thu, Jul 7, 2016 at 9:30 PM, Oscar wrote: > Thanks all for the input. I think it all boils down to: "If you don't > want a space in your long_option, don't put a space in there". Yeah, I guess, pretty much! > Mmm... nope. I'm not going to learn a new tool and introduce an extra > dependency just to do something as basic as getopt. But then again, > coming from a C background, getopt feels kind of familiar. ;-) >>I just put docstrings on my functions, slap "@command" above them, and >>with minimal boilerplate, I have a fully-working command line >>interface. It's a wrapper around argparse. > > Looks neat though! Yes, it's a third-party dependency. (Sorry, should have mentioned that.) You're welcome to consider that to be too much risk and/or hassle to be worth improving on getopt, but personally, I *really* like the simplicity of just writing docstrings that still read perfectly well as docstrings, and having them create my argparse configs for me. Different strokes for different horses, or something like that. ChrisA