Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #99859

Re: Is vars() the most useless Python built-in ever?

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Subject Re: Is vars() the most useless Python built-in ever?
Date Wed, 2 Dec 2015 20:33:17 +1100
Lines 21
Message-ID <mailman.112.1449048800.14615.python-list@python.org> (permalink)
References <565cf141$0$1612$c3e8da3$5496439d@news.astraweb.com> <20151201084416.GA2700@beagle> <n3jtei$fpa$1@ger.gmane.org> <20151201213100.GA9665@beagle.localdomain> <n3l7mi$k6g$1@ger.gmane.org> <20151202090954.GC9665@beagle.localdomain>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
X-Trace news.uni-berlin.de XFtuVUu07nt7pfgtyI+JwA0dkw2h0vSFZb8jCtZm487g==
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'url:pypi': 0.03; 'received:209.85.223': 0.03; 'subject:Python': 0.05; 'main()': 0.07; 'wrapper': 0.07; 'cc:addr:python-list': 0.09; 'url:github': 0.09; 'example:': 0.10; 'anyway': 0.11; 'wed,': 0.15; 'things.': 0.15; 'argparse': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:ever': 0.16; 'subject:most': 0.16; 'url:py': 0.16; 'wrote:': 0.16; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'handles': 0.20; 'help.': 0.23; 'wrote': 0.23; 'dec': 0.23; 'written': 0.24; 'header:In-Reply- To:1': 0.24; 'script': 0.25; "i've": 0.25; 'define': 0.27; 'message-id:@mail.gmail.com': 0.27; 'function': 0.28; 'looks': 0.29; 'url:python': 0.33; 'true.': 0.33; 'similar': 0.33; 'correctly': 0.34; 'received:google.com': 0.35; 'could': 0.35; 'but': 0.36; 'url:org': 0.36; 'received:209.85': 0.36; 'subject:?': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:209': 0.38; 'wrong': 0.38; 'subject:the': 0.39; 'subject:-': 0.39; 'directly.': 0.76; 'chrisa': 0.84; 'clize': 0.84; 'docstrings.': 0.84; 'otten': 0.84; 'this...': 0.84; 'url:clize': 0.84; 'url:master': 0.84; 'to:none': 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:content-transfer-encoding; bh=n+4Hr/SBN/DyzUpmqBJhLRmFPHgmVJ2Zc5/g9C/Zh3Y=; b=kxey8tuKR/ggzRJ+oMLZ6fpL5I7sOzIkxWaOHy033hc4Twy/lwTSLvphKYSbVpuoYU lD5V98VBy+4Jvjlq8M2R3MWVn0/6PzN97ibsUTzcEHSZfRbJYUGmrxImfsPBc5PQmoo+ 3tDkr0YR1HES7XnsYQwBY4aOMASNENhwSyB/2qXQhA8X8cKiO06fQzV81vufHp/jzT23 4DFzrUIIAKg0ejIMfd69cwVc+35lLAo0k/rpkUEYBdEN2FQhqgluJik/vUAGXOj0gmbb m3ktjhn9GBn+ybkd39/M9aQ/weG8hklf9G8P+dYl7BuuY3vuPkHlhXKV7zDfyKnhFJJv 3TJA==
X-Received by 10.107.10.233 with SMTP id 102mr2628270iok.31.1449048797382; Wed, 02 Dec 2015 01:33:17 -0800 (PST)
In-Reply-To <20151202090954.GC9665@beagle.localdomain>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:99859

Show key headers only | View raw


On Wed, Dec 2, 2015 at 8:09 PM, Manolo Martínez
<manolo@austrohungaro.com> wrote:
> Peter Otten wrote:
>> As far as I can see in a correctly written script the AttributeError cannot
>> be triggered by the user as argparse handles this case automatically by
>> showing the help.
>
> This... is true. I could have sworn that's not the way argparse behaved
> when I wrote that snippet, but I've been very wrong before about similar
> things. Anyway my main() function looks much better now :)

I would recommend not using argparse directly. Pick up a wrapper like
clize, and then define everything through docstrings.

Clize usage example:
https://github.com/Rosuav/LetMeKnow/blob/master/letmeknow.py

https://pypi.python.org/pypi/clize

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Is vars() the most useless Python built-in ever? Steven D'Aprano <steve@pearwood.info> - 2015-12-01 12:00 +1100
  Re: Is vars() the most useless Python built-in ever? Josef Pktd <josef.pktd@gmail.com> - 2015-11-30 19:45 -0800
  Re: Is vars() the most useless Python built-in ever? Rick Johnson <rantingrickjohnson@gmail.com> - 2015-11-30 21:54 -0800
    Re: Is vars() the most useless Python built-in ever? Marko Rauhamaa <marko@pacujo.net> - 2015-12-01 09:34 +0200
      Re: Is vars() the most useless Python built-in ever? Rick Johnson <rantingrickjohnson@gmail.com> - 2015-12-11 13:06 -0800
    Re: Is vars() the most useless Python built-in ever? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-12-01 18:55 +1100
      Re: Is vars() the most useless Python built-in ever? Rick Johnson <rantingrickjohnson@gmail.com> - 2015-12-01 12:33 -0800
        Re: Is vars() the most useless Python built-in ever? Steven D'Aprano <steve@pearwood.info> - 2015-12-02 11:57 +1100
        Re: Is vars() the most useless Python built-in ever? Ian Kelly <ian.g.kelly@gmail.com> - 2015-12-01 22:48 -0600
          Re: Is vars() the most useless Python built-in ever? Rick Johnson <rantingrickjohnson@gmail.com> - 2015-12-11 14:13 -0800
            Re: Is vars() the most useless Python built-in ever? Steven D'Aprano <steve@pearwood.info> - 2015-12-12 15:44 +1100
              Re: Is vars() the most useless Python built-in ever? Chris Angelico <rosuav@gmail.com> - 2015-12-12 16:56 +1100
              Re: Is vars() the most useless Python built-in ever? Rick Johnson <rantingrickjohnson@gmail.com> - 2015-12-14 18:33 -0800
      Re: Is vars() the most useless Python built-in ever? Ben Finney <ben+python@benfinney.id.au> - 2015-12-02 12:47 +1100
    Re: Is vars() the most useless Python built-in ever? John Gordon <gordon@panix.com> - 2015-12-01 16:56 +0000
      Re: Is vars() the most useless Python built-in ever? Rick Johnson <rantingrickjohnson@gmail.com> - 2015-12-01 13:15 -0800
        Re: Is vars() the most useless Python built-in ever? "Albert Visser" <albert.visser@gmail.com> - 2015-12-02 19:08 +0100
    Re: Is vars() the most useless Python built-in ever? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2015-12-02 13:14 +1300
  Re: Is vars() the most useless Python built-in ever? eryk sun <eryksun@gmail.com> - 2015-12-01 01:22 -0600
    Re: Is vars() the most useless Python built-in ever? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-12-01 18:57 +1100
  Re: Is vars() the most useless Python built-in ever? Manolo Martínez <manolo@austrohungaro.com> - 2015-12-01 09:44 +0100
    Re: Is vars() the most useless Python built-in ever? Steven D'Aprano <steve@pearwood.info> - 2015-12-02 12:12 +1100
      Re: Is vars() the most useless Python built-in ever? Peter Otten <__peter__@web.de> - 2015-12-02 08:51 +0100
  Re: Is vars() the most useless Python built-in ever? Peter Otten <__peter__@web.de> - 2015-12-01 11:40 +0100
  Re: Is vars() the most useless Python built-in ever? Manolo Martínez <manolo@austrohungaro.com> - 2015-12-01 22:31 +0100
  Re: Is vars() the most useless Python built-in ever? Peter Otten <__peter__@web.de> - 2015-12-01 23:41 +0100
  Re: Is vars() the most useless Python built-in ever? boB Stepp <robertvstepp@gmail.com> - 2015-12-01 20:20 -0600
  Re: Is vars() the most useless Python built-in ever? wxjmfauth@gmail.com - 2015-12-01 23:46 -0800
  Re: Is vars() the most useless Python built-in ever? Serhiy Storchaka <storchaka@gmail.com> - 2015-12-02 10:22 +0200
  Re: Is vars() the most useless Python built-in ever? Manolo Martínez <manolo@austrohungaro.com> - 2015-12-02 10:09 +0100
  Re: Is vars() the most useless Python built-in ever? Chris Angelico <rosuav@gmail.com> - 2015-12-02 20:28 +1100
  Re: Is vars() the most useless Python built-in ever? Chris Angelico <rosuav@gmail.com> - 2015-12-02 20:33 +1100
  Re: Is vars() the most useless Python built-in ever? Manolo Martínez <manolo@austrohungaro.com> - 2015-12-02 10:40 +0100
  Re: Is vars() the most useless Python built-in ever? Peter Otten <__peter__@web.de> - 2015-12-02 11:48 +0100
  Re: Is vars() the most useless Python built-in ever? Chris Angelico <rosuav@gmail.com> - 2015-12-02 22:02 +1100
  Re: Is vars() the most useless Python built-in ever? eryk sun <eryksun@gmail.com> - 2015-12-02 05:34 -0600
  Re: Is vars() the most useless Python built-in ever? Serhiy Storchaka <storchaka@gmail.com> - 2015-12-04 10:42 +0200

csiph-web