On Aug 19, 1:45 pm, Hrvoje Niksic <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] writes: > > 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? > > It has nothing to do with optparse, it's how Python prints strings: > > $ python -c 'import sys; print sys.argv' '\t' > ['-c', '\\t'] > > Note that you're not really passing a control character to Python, > you're passing a two-character string consisting of \ and t. When > representing the string inside a data structure, Python escapes the \ > to avoid confusion with a real control character such as \t. > > If you try printing the string itself, you'll see that everything is > correct: > > $ python -c 'import sys; print sys.argv[1]' '\t' > \t
Thanks for the reply, much clearer now, just one more question. How would I pass a control character to python on the command line? -- http://mail.python.org/mailman/listinfo/python-list