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

Chris Angelico rosuav at gmail.com
Wed Dec 2 04:33:17 EST 2015


On Wed, Dec 2, 2015 at 8:09 PM, Manolo Martínez
<manolo at 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



More information about the Python-list mailing list