472,145 Members | 1,549 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,145 software developers and data experts.

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 2049
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
reply views Thread by Saiars | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.