Issue 13584: argparse doesn't respect double quotes (original) (raw)

Created on 2011-12-11 23:06 by Phillip.M.Feldman, last changed 2022-04-11 14:57 by admin. 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
2022-04-11 14:57:24 admin set github: 57793
2011-12-16 12:53:37 bethard set status: open -> closedmessages: + assignee: bethardresolution: works for mestage: resolved
2011-12-16 01:28:00 Phillip.M.Feldman@gmail.com set nosy: + Phillip.M.Feldman@gmail.commessages: +
2011-12-15 10:22:33 bethard set messages: +
2011-12-12 04:21:21 ned.deily set nosy: + bethard
2011-12-11 23:06:15 Phillip.M.Feldman create