By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,666 Members | 1,222 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,666 IT Pros & Developers. It's quick & easy.

How do I express a backslash in a string?

P: n/a
>>"'"
"'"
>>"\'"
"'"
>>"\\'"
"\\'"
>>"\\\'"
"\\'"
>>>
This is quite different than any other language
that I am used to. Normally, a double backslash
takes away the special meaning of the last backslash,
and so you are left with a single backslash.

How do I express the single backslash?

Thanks,

Tobiah

--
Posted via a free Usenet account from http://www.teranews.com

Aug 22 '07 #1
Share this Question
Share on Google+
2 Replies

P: n/a
Tobiah wrote:
>>>"'"
"'"
>>>"\'"
"'"
>>>"\\'"
"\\'"
>>>"\\\'"
"\\'"
>>>>

This is quite different than any other language
that I am used to. Normally, a double backslash
takes away the special meaning of the last backslash,
and so you are left with a single backslash.

How do I express the single backslash?

Thanks,

Tobiah
A little more looking, and I see:

>>"\\'"
"\\'"
>>len("\\'")
2
>>>

So it was just the console representation that was fooling
me into thinking that I had a double backslash.

--
Posted via a free Usenet account from http://www.teranews.com

Aug 22 '07 #2

P: n/a
On Aug 22, 1:19 pm, Tobiah <t...@tobiah.orgwrote:
>"'"
"'"
>"\'"
"'"
>"\\'"
"\\'"
>"\\\'"
"\\'"

This is quite different than any other language
that I am used to. Normally, a double backslash
takes away the special meaning of the last backslash,
and so you are left with a single backslash.

How do I express the single backslash?

Thanks,

Tobiah
It IS a single backslash - the interpreter in interactive mode
displays the string literal (escaped) version of what you entered,
which is, well, what you entered. If you print it instead, you'll see
the actual string value.
>>'\\'
'\\'
>>print '\\'
\

Fred

Aug 22 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.