[issue14034] Add argparse howto
Tshepang Lekhonkhobe tshep...@gmail.com added the comment: thanks so much for your rime in reviewing and committing -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14034 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14034] Add argparse howto
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset 48385618525b by Ezio Melotti in branch '2.7': #14034: added the argparse tutorial. Patch by Tshepang Lekhonkhobe. http://hg.python.org/cpython/rev/48385618525b New changeset 11703cb2a2f3 by Ezio Melotti in branch '3.2': #14034: added the argparse tutorial. Patch by Tshepang Lekhonkhobe. http://hg.python.org/cpython/rev/11703cb2a2f3 New changeset 645969f4193b by Ezio Melotti in branch 'default': #14034: merge argparse tutorial from 3.2. http://hg.python.org/cpython/rev/645969f4193b -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14034 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14034] Add argparse howto
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset 549aa1460811 by Ezio Melotti in branch '2.7': #14034: adapt to Python 2 and fix indentation. http://hg.python.org/cpython/rev/549aa1460811 New changeset d5b7be0629c0 by Ezio Melotti in branch '3.2': #14034: fix indentation. http://hg.python.org/cpython/rev/d5b7be0629c0 New changeset e14c860f6eee by Ezio Melotti in branch 'default': #14034: merge indentation fixes from 3.2. http://hg.python.org/cpython/rev/e14c860f6eee -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14034 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14034] Add argparse howto
Ezio Melotti ezio.melo...@gmail.com added the comment: Committed, thanks for the patch! (Note that the example with TypeError: unorderable types: NoneType() = int() works fine in Python 2 (by accident), and that I left it unchanged. Some error messages are also different on Python 2, but I left the ones from Python 3.) -- assignee: docs@python - ezio.melotti resolution: - fixed stage: needs patch - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14034 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14034] Add argparse howto
Tshepang Lekhonkhobe tshep...@gmail.com added the comment: Thanks so much for your thorough attention to detail. I've addressed all your latest comments. -- Added file: http://bugs.python.org/file25417/argparse_howto5.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14034 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14034] Add argparse howto
Tshepang Lekhonkhobe tshep...@gmail.com added the comment: addressing the bulk of your comments this does not address last message, where you want the lines highlighted; it will be rather tedious; to me the code snippets are short enough, removing the need for highlighting -- Added file: http://bugs.python.org/file25409/argparse_howto4.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14034 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14034] Add argparse howto
Ezio Melotti ezio.melo...@gmail.com added the comment: Would be nice to get another review. I left several comments on rietveld. Overall the tutorial seems really nice and easy to follow (except a couple of parts, noted in the comments). I would replace all the uses of pow(x, y) with x**y in the code, and possibly with x^y in the output/descriptions (x**y is probably fine there too). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14034 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14034] Add argparse howto
Ezio Melotti ezio.melo...@gmail.com added the comment: A few more comments: * in the review I mentioned highlighting specific code lines (this would be really great given the incremental nature of the howto), but apparently that requires a pygment 1.1 [0]. * all the output examples could use .. highlightlang:: sh, but: 1. the sh highlighter is not so good imho; 2. you would have to switch back and forth from sh and python (unless there's a better way to do it); * the sidebar box with the tutorial looks better if you put it between the hr and the introductory paragraph. Maybe Georg has something to say about the first two comments. [0]: see last example in http://sphinx.pocoo.org/markup/code.html#line-numbers -- nosy: +georg.brandl ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14034 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14034] Add argparse howto
Tshepang Lekhonkhobe tshep...@gmail.com added the comment: Would be nice to get another review. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14034 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14034] Add argparse howto
Tshepang Lekhonkhobe tshep...@gmail.com added the comment: Nick Coghlan ncogh...@gmail.com added the comment: A couple of thoughts on the draft HOWTO: I like the verbosity example, but I'd also like to see it continue on into introducing the action='count' alternative that allows -vv to set the verbosity level to 2, etc. I wonder if this usage is common enough to get an entry in this introductory text. I also find the idea of having higher verbosity levels that aren't supersets of lower verbosity levels to be an anti-pattern, so I'd prefer not to see it in an official HOWTO. To my mind, verbosity levels should be checked with =, never ==. I don't really understand this paragraph. Do you have an example to compare with any of the examples in the attached patch? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14034 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14034] Add argparse howto
Tshepang Lekhonkhobe tshep...@gmail.com added the comment: On Mon, Mar 19, 2012 at 10:34, Tshepang Lekhonkhobe tshep...@gmail.com wrote: Nick Coghlan ncogh...@gmail.com added the comment: A couple of thoughts on the draft HOWTO: I like the verbosity example, but I'd also like to see it continue on into introducing the action='count' alternative that allows -vv to set the verbosity level to 2, etc. I wonder if this usage is common enough to get an entry in this introductory text. I also find the idea of having higher verbosity levels that aren't supersets of lower verbosity levels to be an anti-pattern, so I'd prefer not to see it in an official HOWTO. To my mind, verbosity levels should be checked with =, never ==. I don't really understand this paragraph. Do you have an example to compare with any of the examples in the attached patch? After playing a bit more with this and thinking about it a bit, I do get your point. It makes a lot of sense. I will attach a patch soon, which will also include the count keyword. Thanks for the review. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14034 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14034] Add argparse howto
Tshepang Lekhonkhobe tshep...@gmail.com added the comment: After playing a bit more with this and thinking about it a bit, I do get your point. It makes a lot of sense. I will attach a patch soon, which will also include the count keyword. Thanks for the review. Find attached. Note that I kept some of those anti-pattern examples you mentioned, and then later on introduced your preferred way of doing things (using action=count and = checks instead of == ones). -- Added file: http://bugs.python.org/file24937/argparse_howto2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14034 ___diff --git a/Doc/howto/argparse.rst b/Doc/howto/argparse.rst new file mode 100644 --- /dev/null +++ b/Doc/howto/argparse.rst @@ -0,0 +1,720 @@ +* +Command Line Interface HOWTO +* + +:author: Tshepang Lekhonkhobe tshep...@gmail.com + +.. _argparse-howto: + +This is intended to be a gentle introduction to command line parsing +using :mod:`argparse` module, the recommended module for such a purpose +in Python. Please pay careful attention to the code and its output. All of +it was carefully selected for its instructive value. + +.. note:: + + There's two other modules that fulfill the same task, namely + :mod:`getopt` (an equivalent for :c:func:`getopt` from the C + language) and the deprecated :mod:`optparse`. + + +Concepts + + +Let's show the sort of functionality that we are going to explore in this +introductory tutorial by making use of the :command:`ls` command:: + + +$ ls +cpython devguide prog.py pypy rm-unused-function.patch +$ ls pypy +ctypes_configure demo dotviewer include lib_pypy lib-python ... +$ ls -l +total 20 +drwxr-xr-x 19 wena wena 4096 Feb 18 18:51 cpython +drwxr-xr-x 4 wena wena 4096 Feb 8 12:04 devguide +-rwxr-xr-x 1 wena wena 535 Feb 19 00:05 prog.py +drwxr-xr-x 14 wena wena 4096 Feb 7 00:59 pypy +-rw-r--r-- 1 wena wena 741 Feb 18 01:01 rm-unused-function.patch +$ ls --help +Usage: ls [OPTION]... [FILE]... +List information about the FILEs (the current directory by default). +Sort entries alphabetically if none of -cftuvSUX nor --sort is specified. +... + +A few concepts we can learn from the four commands: + +#. The :command:`ls` command is useful when run without any options at all. It defaults + to displaying the contents of the current directory. + +#. If we want beyond what it provides by default, we tell it a bit more. In + this case, we want it to display a different directory, ``pypy``. + What we did is specify what is known as a positional argument. It's named so + because the program should know what to do with the value, solely based on + where it appears on the command line. This concept is more relevant + to a command like :command:`cp`, whose most basic usage is ``cp SRC DEST``. + The first position is *what you want copied,* and the second + position is *where you want it copied to*. + +#. Now, say we want to change behaviour of the program. In our example, + we display more info for each file instead of just showing the file names. + The ``-l`` in that case is known as an optional argument. + +#. That's a snippet of the help text. It's very useful in that you can + come across a program you have never used before, and can figure out + how it works simply by reading it's help text. + + +The basics +== + +Let us start with a very simple example which does (almost) nothing:: + +import argparse +parser = argparse.ArgumentParser() +parser.parse_args() + +Following is a result of running the code:: + +$ python3 prog.py +$ python3 prog.py --help +usage: prog.py [-h] + +optional arguments: + -h, --help show this help message and exit +$ python3 prog.py --verbose +usage: prog.py [-h] +prog.py: error: unrecognized arguments: --verbose +$ python3 prog.py foo +usage: prog.py [-h] +prog.py: error: unrecognized arguments: foo + +Here is what is happening: + +* Running the script without any options results in nothing displayed to + stdout. Not so useful. + +* The second one starts to display the usefulness of the :mod:`argparse` + module. We have done almost nothing, but already we get a nice help message. + +* The ``--help`` option, which can also be shortened to ``-h``, is the only + option we get for free (i.e. no need to specify it). Specifying anything + else results in an error. But even then, we do get a useful usage message, + also for free. + + +Introducing Positional arguments + + +An example:: + +import argparse +parser = argparse.ArgumentParser() +parser.add_argument(echo) +args = parser.parse_args() +print(args.echo) + +And running the code:: + +$ python3 prog.py +usage: prog.py
[issue14034] Add argparse howto
Tshepang Lekhonkhobe tshep...@gmail.com added the comment: Find attached. Note that I kept some of those anti-pattern examples you mentioned, and then later on introduced your preferred way of doing things (using action=count and = checks instead of == ones). Reason I kept those is to easily lead the reader into the more correct way of doing things, by first doing them in a more obvious but less ideal way. For example, when the goal of one is to teach one to remove duplicates from list, it's nice if you first do the process manually, and then later on introduce the set() type, just so the user can appreciate them more. Same applies to doing for item in range(len(iterable)) vs. for item in iterable. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14034 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14034] Add argparse howto
Tshepang Lekhonkhobe tshep...@gmail.com added the comment: Okay, there was some bad markup on my version 2. Lemme fix. -- Added file: http://bugs.python.org/file24938/argparse_howto2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14034 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14034] Add argparse howto
Changes by Tshepang Lekhonkhobe tshep...@gmail.com: Removed file: http://bugs.python.org/file24937/argparse_howto2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14034 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14034] Add argparse howto
Nick Coghlan ncogh...@gmail.com added the comment: Rather than is recommended by at least one core CPython developer I'd say matches the way the CPython executable handles its own verbosity argument (check the output of python --help) Also, a better fix for the non-orderable types problem is to use default=0 when defining the verbosity arg rather than changing the test in the code. Finally, the not a superset problem that I have with the way the running example uses its verbosity argument is that it uses it to *change* the message that gets displayed, instead of using it to *display more messages* at higher verbosity levels. From that point of view, more idiomatic usage might look something like: if verbosity = 2: print(Running {!r}.format(self.__file__) if verbosity = 1: print(Calculating {}^2.format(args.square) print(answer) However, I'll grant that things like test runners do use their verbosity argument to switch from shorthand progress markers to printing out the test names and results, so I can live with the examples as they are. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14034 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14034] Add argparse howto
Tshepang Lekhonkhobe tshep...@gmail.com added the comment: Nick Coghlan ncogh...@gmail.com added the comment: Rather than is recommended by at least one core CPython developer I'd say matches the way the CPython executable handles its own verbosity argument (check the output of python --help) Done. Also, a better fix for the non-orderable types problem is to use default=0 when defining the verbosity arg rather than changing the test in the code. Done. Finally, the not a superset problem that I have with the way the running example uses its verbosity argument is that it uses it to *change* the message that gets displayed, instead of using it to *display more messages* at higher verbosity levels. From that point of view, more idiomatic usage might look something like: if verbosity = 2: print(Running {!r}.format(self.__file__) if verbosity = 1: print(Calculating {}^2.format(args.square) print(answer) Yeah, I clearly didn't understand what you meant by 'superset'. I've added one example similar to the above. These were good suggestions. I've attached the patch. -- Added file: http://bugs.python.org/file24941/argparse_howto3.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14034 ___diff --git a/Doc/howto/argparse.rst b/Doc/howto/argparse.rst new file mode 100644 --- /dev/null +++ b/Doc/howto/argparse.rst @@ -0,0 +1,755 @@ +* +Command Line Interface HOWTO +* + +:author: Tshepang Lekhonkhobe tshep...@gmail.com + +.. _argparse-howto: + +This is intended to be a gentle introduction to command line parsing +using :mod:`argparse` module, the recommended module for such a purpose +in Python. Please pay careful attention to the code and its output. All of +it was carefully selected for its instructive value. + +.. note:: + + There's two other modules that fulfill the same task, namely + :mod:`getopt` (an equivalent for :c:func:`getopt` from the C + language) and the deprecated :mod:`optparse`. + + +Concepts + + +Let's show the sort of functionality that we are going to explore in this +introductory tutorial by making use of the :command:`ls` command:: + + +$ ls +cpython devguide prog.py pypy rm-unused-function.patch +$ ls pypy +ctypes_configure demo dotviewer include lib_pypy lib-python ... +$ ls -l +total 20 +drwxr-xr-x 19 wena wena 4096 Feb 18 18:51 cpython +drwxr-xr-x 4 wena wena 4096 Feb 8 12:04 devguide +-rwxr-xr-x 1 wena wena 535 Feb 19 00:05 prog.py +drwxr-xr-x 14 wena wena 4096 Feb 7 00:59 pypy +-rw-r--r-- 1 wena wena 741 Feb 18 01:01 rm-unused-function.patch +$ ls --help +Usage: ls [OPTION]... [FILE]... +List information about the FILEs (the current directory by default). +Sort entries alphabetically if none of -cftuvSUX nor --sort is specified. +... + +A few concepts we can learn from the four commands: + +#. The :command:`ls` command is useful when run without any options at all. It defaults + to displaying the contents of the current directory. + +#. If we want beyond what it provides by default, we tell it a bit more. In + this case, we want it to display a different directory, ``pypy``. + What we did is specify what is known as a positional argument. It's named so + because the program should know what to do with the value, solely based on + where it appears on the command line. This concept is more relevant + to a command like :command:`cp`, whose most basic usage is ``cp SRC DEST``. + The first position is *what you want copied,* and the second + position is *where you want it copied to*. + +#. Now, say we want to change behaviour of the program. In our example, + we display more info for each file instead of just showing the file names. + The ``-l`` in that case is known as an optional argument. + +#. That's a snippet of the help text. It's very useful in that you can + come across a program you have never used before, and can figure out + how it works simply by reading it's help text. + + +The basics +== + +Let us start with a very simple example which does (almost) nothing:: + +import argparse +parser = argparse.ArgumentParser() +parser.parse_args() + +Following is a result of running the code:: + +$ python3 prog.py +$ python3 prog.py --help +usage: prog.py [-h] + +optional arguments: + -h, --help show this help message and exit +$ python3 prog.py --verbose +usage: prog.py [-h] +prog.py: error: unrecognized arguments: --verbose +$ python3 prog.py foo +usage: prog.py [-h] +prog.py: error: unrecognized arguments: foo + +Here is what is happening: + +* Running the script without any options results in nothing displayed to + stdout. Not so useful. + +* The second one starts to display the usefulness of
[issue14034] Add argparse howto
Tshepang Lekhonkhobe tshep...@gmail.com added the comment: Fixing a markup error. Sorry for the noise. -- Added file: http://bugs.python.org/file24942/argparse_howto3.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14034 ___diff --git a/Doc/howto/argparse.rst b/Doc/howto/argparse.rst new file mode 100644 --- /dev/null +++ b/Doc/howto/argparse.rst @@ -0,0 +1,755 @@ +* +Command Line Interface HOWTO +* + +:author: Tshepang Lekhonkhobe tshep...@gmail.com + +.. _argparse-howto: + +This is intended to be a gentle introduction to command line parsing +using :mod:`argparse` module, the recommended module for such a purpose +in Python. Please pay careful attention to the code and its output. All of +it was carefully selected for its instructive value. + +.. note:: + + There's two other modules that fulfill the same task, namely + :mod:`getopt` (an equivalent for :c:func:`getopt` from the C + language) and the deprecated :mod:`optparse`. + + +Concepts + + +Let's show the sort of functionality that we are going to explore in this +introductory tutorial by making use of the :command:`ls` command:: + + +$ ls +cpython devguide prog.py pypy rm-unused-function.patch +$ ls pypy +ctypes_configure demo dotviewer include lib_pypy lib-python ... +$ ls -l +total 20 +drwxr-xr-x 19 wena wena 4096 Feb 18 18:51 cpython +drwxr-xr-x 4 wena wena 4096 Feb 8 12:04 devguide +-rwxr-xr-x 1 wena wena 535 Feb 19 00:05 prog.py +drwxr-xr-x 14 wena wena 4096 Feb 7 00:59 pypy +-rw-r--r-- 1 wena wena 741 Feb 18 01:01 rm-unused-function.patch +$ ls --help +Usage: ls [OPTION]... [FILE]... +List information about the FILEs (the current directory by default). +Sort entries alphabetically if none of -cftuvSUX nor --sort is specified. +... + +A few concepts we can learn from the four commands: + +#. The :command:`ls` command is useful when run without any options at all. It defaults + to displaying the contents of the current directory. + +#. If we want beyond what it provides by default, we tell it a bit more. In + this case, we want it to display a different directory, ``pypy``. + What we did is specify what is known as a positional argument. It's named so + because the program should know what to do with the value, solely based on + where it appears on the command line. This concept is more relevant + to a command like :command:`cp`, whose most basic usage is ``cp SRC DEST``. + The first position is *what you want copied,* and the second + position is *where you want it copied to*. + +#. Now, say we want to change behaviour of the program. In our example, + we display more info for each file instead of just showing the file names. + The ``-l`` in that case is known as an optional argument. + +#. That's a snippet of the help text. It's very useful in that you can + come across a program you have never used before, and can figure out + how it works simply by reading it's help text. + + +The basics +== + +Let us start with a very simple example which does (almost) nothing:: + +import argparse +parser = argparse.ArgumentParser() +parser.parse_args() + +Following is a result of running the code:: + +$ python3 prog.py +$ python3 prog.py --help +usage: prog.py [-h] + +optional arguments: + -h, --help show this help message and exit +$ python3 prog.py --verbose +usage: prog.py [-h] +prog.py: error: unrecognized arguments: --verbose +$ python3 prog.py foo +usage: prog.py [-h] +prog.py: error: unrecognized arguments: foo + +Here is what is happening: + +* Running the script without any options results in nothing displayed to + stdout. Not so useful. + +* The second one starts to display the usefulness of the :mod:`argparse` + module. We have done almost nothing, but already we get a nice help message. + +* The ``--help`` option, which can also be shortened to ``-h``, is the only + option we get for free (i.e. no need to specify it). Specifying anything + else results in an error. But even then, we do get a useful usage message, + also for free. + + +Introducing Positional arguments + + +An example:: + +import argparse +parser = argparse.ArgumentParser() +parser.add_argument(echo) +args = parser.parse_args() +print(args.echo) + +And running the code:: + +$ python3 prog.py +usage: prog.py [-h] echo +prog.py: error: the following arguments are required: echo +$ python3 prog.py --help +usage: prog.py [-h] echo + +positional arguments: + echo + +optional arguments: + -h, --help show this help message and exit +$ python3 prog.py foo +foo + +Here is what's happening: + +#. We've added :meth:`add_argument` method,
[issue14034] Add argparse howto
Changes by Tshepang Lekhonkhobe tshep...@gmail.com: Removed file: http://bugs.python.org/file24941/argparse_howto3.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14034 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14034] Add argparse howto
Tshepang Lekhonkhobe tshep...@gmail.com added the comment: friendly ping -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14034 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14034] Add argparse howto
Éric Araujo mer...@netwok.org added the comment: I’m going to Rietveld to review the patch. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14034 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14034] Add argparse howto
Éric Araujo mer...@netwok.org added the comment: Sorry, a burger party fell on me. I’ll make time this week. Nick, I just read on python-dev that you had suggestions for argparse docs; could you post the bug numbers / message IDs here or the list of suggestions? -- nosy: +ncoghlan ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14034 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14034] Add argparse howto
Nick Coghlan ncogh...@gmail.com added the comment: 13850 (already mentioned above) is my relevant argparse docs proposal - it turns out the other argparse issues I remembered posting were actual feature requests rather than docs suggestions (FWIW, those are 14037 and 14039) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14034 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14034] Add argparse howto
Nick Coghlan ncogh...@gmail.com added the comment: A couple of thoughts on the draft HOWTO: I like the verbosity example, but I'd also like to see it continue on into introducing the action='count' alternative that allows -vv to set the verbosity level to 2, etc. I also find the idea of having higher verbosity levels that aren't supersets of lower verbosity levels to be an anti-pattern, so I'd prefer not to see it in an official HOWTO. To my mind, verbosity levels should be checked with =, never ==. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14034 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14034] Add argparse howto
Éric Araujo mer...@netwok.org added the comment: You might want to coordinate with Issue 13850 a bit - they want a quick reference table before the first example (which would therefore mean before this howto which is replacing the first example). The howto discussed here would be a new file in Doc/howto, so no conflict. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14034 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14034] Add argparse howto
Steven Bethard steven.beth...@gmail.com added the comment: Oh ok. Sounds good then! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14034 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14034] Add argparse howto
Steven Bethard steven.beth...@gmail.com added the comment: I have no objections on adding a howto, and something like the attached patch would be fine with me (though I don't have time to review it in full and trust you to). You might want to coordinate with Issue 13850 a bit - they want a quick reference table before the first example (which would therefore mean before this howto which is replacing the first example). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14034 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14034] Add argparse howto
Éric Araujo mer...@netwok.org added the comment: Nice. I’ll find time to review later; Steven, do you have objections on the idea of adding an argparse howto? Do you want to review it yourself? -- nosy: +bethard title: first example in argparse doc is too complicated - Add argparse howto ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14034 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com