constructing binary \n
Steven Arnold
stevena at neosynapse.net
Wed Sep 29 21:28:02 EDT 2004
Is there a more elegant way to construct \[a-z] in a string than
something like:
s = '\\n'
result = eval( "'%s'" ) % s
Another ugly method would be to build a dict with all the different
special letters I want as keys, and their corresponding values as
values. Or I could have a huge if/elif structure. I can't make ord
work, because while ord( '\n' ) gives me a reasonable integer that I
can interpolate with %c, I don't have '\n', I have '\\n'.
Is there a simple, graceful way to do this sort of translation?
steve
More information about the Python-list
mailing list