Use the pycolor tool included with ipython. It will format the source using ASCII codes so it looks pretty in your terminal:
$ pycolor foo.py
asciicommandsipythonlanguagesprogrammingpycolorpythonterminal
In Python you can use the array module to quickly convert ASCII values to a string and back again.
>>> import array
>>> array.array('B', [97, 98, 99]).tostring()
'abc'
>>> array.array('B', 'abc').tolist()
[97, 98, 99]
For more information, read Python Patterns - An Optimization Anecdote.
arraysasciiconversionmodulesoptimizationpython
With the following code you can be rid of control characters forever:
$string_with_ctrl_characters =~ tr/\040-\176/ /c;
asciicontrolperl