This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Python 2 error in Argparse tutorial
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: Charlie.Dimino, berker.peksag, docs@python, ezio.melotti, pconnell, python-dev, r.david.murray, terry.reedy, tshepang
Priority: normal Keywords: easy

Created on 2013-01-04 16:37 by Charlie.Dimino, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (11)
msg179041 - (view) Author: Charlie Dimino (Charlie.Dimino) Date: 2013-01-04 16:37
http://docs.python.org/2/howto/argparse.html

Error message in the first example is outdated, may indicate further out of date information on page.

Example:

The tutorial says:
prog.py: error: the following arguments are required: echo

When the actual error received is:
prog.py: error: too few arguments
msg179043 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013-01-04 16:56
Actually it looks like it is future-dated.  The documented error message is the one you get from 3.3.  I guess someone backported a doc change for a feature change.
msg179044 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013-01-04 16:59
Ah, the whole tutorial is newish.  So this is a bug just in the 2.7 version of the tutorial (it doesn't match the 2.7 code), and yes, there may be other issues as well.
msg179045 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013-01-04 17:01
See issue 14034.  Ezio apparently left the error messages unchanged on purpose...I'm not sure why.
msg179050 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2013-01-04 17:24
When I backported the patch I probably didn't want to try all the examples to see what the py2 error was.  In addition the py3 error is more clear even if it doesn't match what you actually get.
I think this can be closed as won't fix, unless someone wants to propose a patch.
msg179052 - (view) Author: Charlie Dimino (Charlie.Dimino) Date: 2013-01-04 17:31
If it's okay, don't close this just yet. I'm new to this system but I'll submit a patch with any fixes to the tutorial I find.
msg179108 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2013-01-05 04:17
A quick patch would be 'This tutorial was written for argparse in Python 3. A few details are different in 2.x.' But feel free to do better.
msg179115 - (view) Author: Tshepang Lekhonkhobe (tshepang) * Date: 2013-01-05 08:16
> A quick patch would be 'This tutorial was written for argparse in Python 3. A few details are different in 2.x.' But feel free to do better.

That really sounds great, especially since it avoids resorting to
things as ugly as "...and this is Python 2 output".
msg229836 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-10-22 21:45
Since the author of the tutorial agrees with my idea, and no one has come forward with anything else, I will make the change.
msg229837 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-10-22 22:00
New changeset e7428d7f641f by Terry Jan Reedy in branch '2.7':
Issue #16863: Explain difference between text and 2.7 behavior.
https://hg.python.org/cpython/rev/e7428d7f641f
msg229839 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-10-22 22:04
Once this discrepancy is explained
(3.x) prog.py: error: the following arguments are required: echo
(2.7) prog.py: error: too few arguments
I agree with leaving the 3.x version in the tutorial.  A normal output discrepany might be a different matter.
History
Date User Action Args
2022-04-11 14:57:40adminsetgithub: 61067
2014-10-22 22:04:46terry.reedysetstatus: open -> closed
resolution: fixed
messages: + msg229839

stage: needs patch -> resolved
2014-10-22 22:00:16python-devsetnosy: + python-dev
messages: + msg229837
2014-10-22 21:45:53terry.reedysetassignee: terry.reedy
messages: + msg229836
2014-10-22 21:03:45berker.peksagsetkeywords: + easy
nosy: + berker.peksag

stage: needs patch
2013-04-19 19:38:01pconnellsetnosy: + pconnell
2013-01-05 08:16:07tshepangsetmessages: + msg179115
2013-01-05 04:17:21terry.reedysetnosy: + terry.reedy
messages: + msg179108
2013-01-04 18:52:13tshepangsettitle: Argparse tutorial outdated -> Python 2 error in Argparse tutorial
2013-01-04 17:31:18Charlie.Diminosetmessages: + msg179052
2013-01-04 17:24:20ezio.melottisettype: enhancement
messages: + msg179050
2013-01-04 17:01:49r.david.murraysetassignee: docs@python -> (no value)

messages: + msg179045
nosy: + ezio.melotti, tshepang
2013-01-04 16:59:21r.david.murraysetmessages: + msg179044
2013-01-04 16:56:50r.david.murraysetnosy: + r.david.murray
messages: + msg179043
2013-01-04 16:37:44Charlie.Diminocreate