469,587 Members | 2,733 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,587 developers. It's quick & easy.

How do I express a backslash in a string?

>>"'"
"'"
>>"\'"
"'"
>>"\\'"
"\\'"
>>"\\\'"
"\\'"
>>>
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
2 1953
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
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.

Similar topics

3 posts views Thread by Terry Asher | last post: by
6 posts views Thread by John Salerno | last post: by
3 posts views Thread by Stef Mientki | last post: by
1 post views Thread by Dravidan | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.