A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2001-April/091310.html below:

backslashes and strings

backslashes and strings backslashes and stringsSteve Holden sholden at holdenweb.com
Tue Apr 24 14:51:07 EDT 2001
"Harald Kirsch" <kirschh at lionbioscience.com> wrote in message
news:yv2bspmba7b.fsf at lionsp093.lion-ag.de...
>
> Do I understand this correctly?
>
> >>> x='\\\\s'
> >>> x
> '\\\\s'
> >>> len(x)
> 3
>
> After assignment x contains a string with 3 characters, in particular
> 2 backslashes and an `s'. Typing x and <RETURN> gives me a
> representation of the value of x in a way that it could be parsed
> again into the true value of x. Right?
>
> Now continuing the example:
>
> >>> eval('"'+x+'"')
> '\\s'
> >>> print eval('"'+x+'"')
> \s
> >>> print len(eval('"'+x+'"'))
> 2
>
> This, in effect, runs the expression "\\s" which internally denotes a
> string with two characters, namely a backslash and an `s'.
>
Far more correctly than many, I should say.

regards
 STeve



More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4