<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Στις 19/8/2010 6:58 μμ, ο/η Tim Chase έγραψε:
<blockquote cite="mid:4C6D548F.2050303@tim.thechases.com"
type="cite">It can be written as a non-3-quote string, you just
have to escape the inner quotes (single & double) and the
backslash to be seen:
<br>
<br>
name = 'My name is "Nikos" and I\'m from Thessaloniki\\Greece'
<br>
name = "My name is \"Nikos\" and I'm from Thessaloniki\\Greece"
<br>
<br>
</blockquote>
<br>
So if i enclose the string in double quotes the inner double quotes
have to be escaped while<br>
if i enclose the string in single quotes the inner single quotes
have to be escaped.<br>
<br>
But in 3-single-quoting thing became easier since i don't have to
escape all kind of quotes right? just the backslashes.<br>
<br>
<blockquote cite="mid:4C6D548F.2050303@tim.thechases.com"
type="cite">
<blockquote type="cite" style="color: rgb(0, 0, 0);">And i dont
have to use the 'r' in fornt of it too.
<br>
</blockquote>
<br>
Using the 'r' in front would make it much more challenging,
because it would prevent the backslashes from being seen as
escaping. <span class="moz-smiley-s1" title=":)"><span>:)</span></span>
<br>
</blockquote>
<br>
<span class="Apple-style-span" style="border-collapse: separate;
color: rgb(51, 51, 51); font-family: 'Times New Roman'; font-size:
19px; font-style: normal; font-variant: normal; font-weight:
normal; letter-spacing: normal; line-height: normal; orphans: 2;
text-indent: 0px; text-transform: none; white-space: normal;
widows: 2; word-spacing: 0px;"><span class="Apple-style-span"
style="color: rgb(0, 0, 0); font-family: 'Lucida
Grande','Trebuchet MS',Verdana,Helvetica,Arial,sans-serif;
font-size: 15px; line-height: 21px;">So the best way to write
the above assignment statement would be:<br>
<br>
</span></span>name = r'''My name is "Nikos" and I'm from
Thessaloniki\Greece''' <br>
<br>
It cannot get any easier that that can it? :) <br>
<br>
''' ''' helps avoid escaping all kind of quotes!<br>
'r' avoid escaping backslashes! <br>
<span class="Apple-style-span" style="border-collapse: separate;
color: rgb(51, 51, 51); font-family: 'Times New Roman'; font-size:
19px; font-style: normal; font-variant: normal; font-weight:
normal; letter-spacing: normal; line-height: normal; orphans: 2;
text-indent: 0px; text-transform: none; white-space: normal;
widows: 2; word-spacing: 0px;"><span class="Apple-style-span"
style="color: rgb(0, 0, 0); font-family: 'Lucida
Grande','Trebuchet MS',Verdana,Helvetica,Arial,sans-serif;
font-size: 15px; line-height: 21px;"><br>
=============================<br>
Why does the page variable which is actually a string needs to
be a tuple or a list and not just as a string which is what it
actually is?</span></span><br>
I have a strong desire to use it like this:<br>
<br>
cursor.execute( '''SELECT hits FROM counters WHERE page = %s''' ,
page )<br>
<br>
opposed to tuple. Would i might facing a problem? Of what? MySQLdb
instead of give the whole value to the placeholder to give just a
single char?<br>
Also do i need 3-single-quoting here as well or it can be written
qith signle/double quotes?<br>
What appleis to strings apply to mysql queries as well?<br>
</body>
</html>