Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: Spot the bug: getoptquestion.py Date: Mon, 4 Jul 2016 23:42:25 +1000 Lines: 14 Message-ID: References: <577a4766$0$5839$e4fe514c@news.xs4all.nl> <577a58b9$0$5902$e4fe514c@news.xs4all.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de 9IWr9PH6qlnfYxmj7TU3HgStzNZQRxxtFsUTwKHZb+Ig== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'subject:bug': 0.05; 'trailing': 0.07; 'wrapper': 0.07; 'cc:addr:python-list': 0.09; 'delimiter': 0.09; 'unexpected': 0.09; '2016': 0.16; 'argparse': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; '(usually': 0.22; 'bug?': 0.22; 'function,': 0.22; 'parameter': 0.22; 'strip': 0.22; 'bit': 0.23; 'header:In-Reply-To:1': 0.24; 'mon,': 0.24; 'module': 0.25; "i've": 0.25; 'sense': 0.26; 'least': 0.27; 'message- id:@mail.gmail.com': 0.27; 'behaviour': 0.29; 'command-line': 0.29; 'spaces': 0.29; 'them?': 0.29; 'received:google.com': 0.35; 'but': 0.36; 'instead': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'why': 0.39; 'does': 0.39; 'subject:the': 0.39; 'along': 0.39; 'space': 0.40; 'some': 0.40; 'matter.': 0.66; 'jul': 0.72; 'chrisa': 0.84; 'cuts': 0.84; 'duplication,': 0.84; 'oscar': 0.84; 'to:none': 0.91; 'subject:skip:g 10': 0.91; 'hand,': 0.97 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=5br92/cHqhQ3mWxNYKM6bJN0J2i0yWRkqXtxqZdessU=; b=xb7ogUx1Ij3zZ6xZjBng/jZ9oqAGKeXQdH+FNj2AFtO+ukJ4zisIDJ3Vy1Hp7sy992 UK6rSn1Xtf2JvWBq3ptb2XvgnlY+ZisnLgWfFGpQZ1iRISuQeTj6RF/lRerWrjDytdSm ZLZAbRIoG/dHRtc32z34TvfDE/bn+WwutAFLfNRS39tQDQsADkdEAzOy1RzKcFKwBH3Y VZ6Bs8RsBc9mW+IeAUMZPGHT4hol8gYevKi0LzqzH6jtSRwMUmMVm6LwN/2NK/tx9V0D 3Sig/zgk0ALn+oNnrtToZcEbikJTvi6hxD0ZJ4W6DiJ6ZBaQEE3o69ZJo0YkEayazntN f7Kg== 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=5br92/cHqhQ3mWxNYKM6bJN0J2i0yWRkqXtxqZdessU=; b=W3QRgbpGsmM8dvYCGBd/n9pJGDkxh0YfzX6Xpf/DIpH382+nfVmraqom0UdZevDGw2 DwMOzH9L6zG24SiIV0huTqOKbOr+4F/C0HR3kd/CKWY6J6cPwT+Og73QO857ld3i/UiV 0btwaHSMrYGzvFJzCEjoYrNkgkFOe44yr/RMnXz87N9qolbYJEz1lcvjPC9C02Yg5432 69kRM+T1cgxaO4FqNu+I7OF6gy1r0MJvvD6gy+U4d62rigPTXDzsKbBe+2nK8zVTsafc KXsi7v7w91+1CrXX7fdtR0XLazE0OBTWHkPG4FT+P4nzKz2NFS5GthOwtPTnmygVtU0d nxlw== X-Gm-Message-State: ALyK8tLJRsiX1Ucum87oJQBXC2oz+HtY/JvJqT6NDeekDevvsN+I8CLJCBNy3cfJvb9u2ofqbXAaed2t/qHQIg== X-Received: by 10.28.67.69 with SMTP id q66mr10493020wma.81.1467639745765; Mon, 04 Jul 2016 06:42:25 -0700 (PDT) In-Reply-To: <577a58b9$0$5902$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> <577a58b9$0$5902$e4fe514c@news.xs4all.nl> Xref: csiph.com comp.lang.python:111073 On Mon, Jul 4, 2016 at 10:38 PM, Oscar wrote: > But is this not at least a bit unexpected behaviour from getopt? On one > hand, if I want to have trailing spaces in my longoptions, why not just > play along and allow them? On the other hand, a space is a delimiter on > the commandline. Does it make sense to allow it as a parameter to > getopt()? And if getopt would silently strip it, would that be a bug? > This is really the crux of the matter. Honestly, I've no idea. The getopt module is designed to match the C getopt function, which I've never used; for my command-line parsing, I use argparse instead (usually via some wrapper that cuts down the duplication, like clize). ChrisA