classification
Title: argparse doesn't respect double quotes
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: bethard Nosy List: Phillip.M.Feldman, Phillip.M.Feldman@gmail.com, bethard
Priority: normal Keywords:

Created on 2011-12-11 23:06 by Phillip.M.Feldman, last changed 2011-12-16 12:53 by bethard. This issue is now closed.

Messages (4)
msg149258 - (view) Author: Phillip Feldman (Phillip.M.Feldman) Date: 2011-12-11 23:06
I tried switching from `optparse` to `argparse`, but ended up reverting back because `argparse` does not respect double quotes.  For example, `optparse` correctly parses the following, while `argparse` does not:

   python myprog.py --ng --INP="Demo IO"

(`argparse` splits "Demo" and "IO" into separate tokens).
msg149525 - (view) Author: Steven Bethard (bethard) * (Python committer) Date: 2011-12-15 10:22
Can you submit some example code that shows this? I can't reproduce this with:

---------- temp.py ----------
import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--ng", action="store_true")
parser.add_argument("--INP")
print(parser.parse_args())
------------------------------

$ python temp.py --ng --INP="Demo IO"
Namespace(INP='Demo IO', ng=True)
msg149589 - (view) Author: Phillip M. Feldman (Phillip.M.Feldman@gmail.com) Date: 2011-12-16 01:27
Hello Steven,

I'm embarrassed to report that I can't reproduce the problem.  The
input line is parsed correctly if I enclose the string 'Demo IO' in
double quotes.  It is parsed incorrectly if I enclose it in single
quotes, but it looks as though this is the fault of the Windows shell,
and not Python.

My apologies.

Phillip

On Thu, Dec 15, 2011 at 2:22 AM, Steven Bethard <report@bugs.python.org> wrote:
>
> Steven Bethard <steven.bethard@gmail.com> added the comment:
>
> Can you submit some example code that shows this? I can't reproduce this with:
>
> ---------- temp.py ----------
> import argparse
>
> parser = argparse.ArgumentParser()
> parser.add_argument("--ng", action="store_true")
> parser.add_argument("--INP")
> print(parser.parse_args())
> ------------------------------
>
> $ python temp.py --ng --INP="Demo IO"
> Namespace(INP='Demo IO', ng=True)
>
> ----------
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue13584>
> _______________________________________
msg149618 - (view) Author: Steven Bethard (bethard) * (Python committer) Date: 2011-12-16 12:53
Closing then. Thanks for checking it again!
History
Date User Action Args
2011-12-16 12:53:37bethardsetstatus: open -> closed
messages: + msg149618

assignee: bethard
resolution: works for me
stage: resolved
2011-12-16 01:28:00Phillip.M.Feldman@gmail.comsetnosy: + Phillip.M.Feldman@gmail.com
messages: + msg149589
2011-12-15 10:22:33bethardsetmessages: + msg149525
2011-12-12 04:21:21ned.deilysetnosy: + bethard
2011-12-11 23:06:15Phillip.M.Feldmancreate