Return to Home Page
      Blog     Consulting     Seminars     Calendar     Books     CD-ROMS     Newsletter     About     FAQ      Search
 

There are also u"strings" which are unicode, and there
are ur"...." for unicode raw strings. These are described
in the current version of the Python Tutorial by
Guido van Rossum in section 3.1.3 (at the Python.org
website).

It is also worth nothing that these strings are Python
objects and that one can invoke string methods on them
just as one would through a variable. I can say:


x="This is a STRING".lower()

... just as easily as:


x="This is a STRING"
x=x.lower()

(And Unicode strings have .encode() methods to
return their ASCII, Latin-1, UTF-8 and UTF-16
representations).

f  e  x


You should perhaps also mention that the raw switch is especially useful for Window's path names and for regular expressions.

f  e  x


Why? Premise --- I don't know a thing about Python, but here it's just quoting/escaping. In no point of the section is said about a special function of backslash as an escape character. If you need a special token in front of a string to put raw backslashes in it, I argue, in ordinary strings backslash is used as a *meta*character, perhaps to do some escaping. But the text does not speak about it. More in general, I feel this subsection is not very clear. You say how to escape character/sequence x with character/sequence y, and y with z, but without coming to fixpoint. For instance, how do you escape triple quotes? How about if I want to put in the *same* string ", ', """, \?

f  e  x


Backslash will still escape " or ' in a r'raw string'. This feature was designed for regular expressions, not Windows path names.

f  e  x



Add your comment below. Use an empty line between each paragraph. Paragraphs will be automatically formatted, and single carriage returns will be respected. Use <code> to begin a code block, and </code> to end a code block. Your email address will not be visible to spam harvesters or used in any way except to contact you with further questions.

Your Email Address:

Search     Home     WebLog     Consulting     Seminars     Calendar     Books     CD-ROMS     Newsletter     About     Contact     Site Design     Server Maintenance     Powered by Zope
©2007 MindView, Inc.