optparse escaping control characters

Fredrik Lundh fredrik at pythonware.com
Tue Aug 19 14:57:49 CEST 2008

wannymahoots at gmail.com wrote:

> optparse seems to be escaping control characters that I pass as
> arguments on the command line.  Is this a bug?  Am I missing
> something?

you're missing the distinction between the content of a string object, 
and how the corresponding string literal looks.

 >>> x = {'delimiter': '\\t'}
 >>> x
{'delimiter': '\\t'}
 >>> x["delimiter"]
 >>> print x["delimiter"]
 >>> len(x["delimiter"])


More information about the Python-list mailing list