Latest recipes tagged "chr"http://code.activestate.com/recipes/tags/chr/new/2010-04-02T08:20:50-07:00ActiveState Code RecipesClean a .py file full of constant chr(x) calls (Python)
2010-04-02T08:20:50-07:00Marcelo Fernándezhttp://code.activestate.com/recipes/users/4173551/http://code.activestate.com/recipes/577175-clean-a-py-file-full-of-constant-chrx-calls/
<p style="color: grey">
Python
recipe 577175
by <a href="/recipes/users/4173551/">Marcelo Fernández</a>
(<a href="/recipes/tags/chr/">chr</a>, <a href="/recipes/tags/cleaner/">cleaner</a>, <a href="/recipes/tags/cleaning/">cleaning</a>, <a href="/recipes/tags/regex/">regex</a>).
</p>
<p>This script identifies every chr(xx) call in a script (being xx an integer) and replaces it with a constant byte string. For example: print chr(13) + chr(255) in the input .py file gets translated into '\n' + '\xff' on the output .py file, not breaking the input program, and maybe speeding it a little.</p>