optparse escaping control characters

Hrvoje Niksic hniksic at xemacs.org
Tue Aug 19 09:41:37 EDT 2008


Dan Halligan <dan.halligan at gmail.com> writes:

> How would I pass a control character to python on the command line?

It depends on which command line you are using.  Most Unix-like shells
will allow you to input a control character by preceding it with ^V.
Since \t is the TAB character, you should be able to input it like
this:

$ python -c 'import sys; print sys.argv' '^V<tab>'
['-c', '\t']     # note single backslash



More information about the Python-list mailing list