interpretation of special characters in Python
ppearson at nowhere.invalid
Tue Jul 8 06:01:05 CEST 2008
On Mon, 07 Jul 2008 10:05:56 +0200, TP <Tribulations at Paralleles.invalid> wrote:
> TP wrote:
>> So, the python print command *can* interpret these 4-character as a single
>> character. It would be odd if there were no possibility to do the same
>> thing when the characters are (i) stored in a python variable
> Sorry, it works when using variables. Try for example:
> print esc + col + "foobar" + esc + colreset
I don't understand exactly what you mean by "Sorry", but
let me direct your attention to the fact that the "interpretation"
step about which we're talking happens during the parsing
of the string literal (i.e., while the statement esc="\033" is
processed), not during the execution of the print statement.
To prove this assertion, simply print len(esc). You will see
that esc is a single character long.
To email me, substitute nowhere->spamcop, invalid->net.
More information about the Python-list