optparse seems to be escaping control characters that I pass as
arguments on the command line. Is this a bug? Am I missing
something? Can this be prevented, or worked around?
This behaviour doesn't occur with non-control characters.
For example, if this program (called test.py):
from optparse import OptionParser
parser = OptionParser()
parser.add_option("-d", dest="delimiter", action="store")
(options, args) = parser.parse_args()
print options
is run as follows:
python test.py -d '\t'
it outputs:
{'delimiter': '\\t'}
i.e. the \t has had an escape character added to give \\t.
--
http://mail.python.org/mailman/listinfo/python-list