<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 03/06/2014 11:46 PM, Crístian Viana
wrote:<br>
</div>
<blockquote cite="mid:5318985B.7000600@linux.vnet.ibm.com"
type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
Am 06-03-2014 12:12, schrieb Sheldon:<br>
<blockquote cite="mid:5318907A.1070406@linux.vnet.ibm.com"
type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
AFAK, seems two types has no string representation, one is
unicode and another is object derived from nothing.<br>
</blockquote>
The statement <tt>if not isinstance(value, unicode)</tt>, which
is in the sample code above, makes sure that we will not try to
convert a unicode object to string (only those who have a
different type).<br>
</blockquote>
I have forgot to tell one result I have tried:<br>
In [24]: u"fǒǒ = %s" % "fǒǒ"<br>
---------------------------------------------------------------------------<br>
UnicodeDecodeError Traceback (most recent
call last)<br>
<br>
only this case need the statement <tt>if not isinstance(value,
unicode)</tt>,<br>
In [23]: u"fǒǒ = %s" % u"fǒǒ"<br>
Out[23]: u'f\u01d2\u01d2 = f\u01d2\u01d2'<br>
<br>
not find other case. <br>
<br>
if you find, you can tell us. <br>
Thanks. <br>
<br>
<blockquote cite="mid:5318985B.7000600@linux.vnet.ibm.com"
type="cite"> <br>
And an object derived from nothing also has a string
representation. Take a look at this example:<br>
<br>
<tt>>>> class X():</tt><tt><br>
</tt><tt>... def x(self):</tt><tt><br>
</tt><tt>... pass</tt><tt><br>
</tt><tt>... </tt><tt><br>
</tt><tt>>>> a = X()</tt><tt><br>
</tt><tt>>>> print str(a)</tt><tt><br>
</tt><tt><__main__.X instance at 0x7f8fe13d4b00></tt><tt><br>
</tt><tt>>>> print "this is a string: %s." % a</tt><tt><br>
</tt><tt>this is a string: <__main__.X instance at
0x7f8fe13d4b00>.</tt><br>
<br>
<blockquote cite="mid:5318907A.1070406@linux.vnet.ibm.com"
type="cite">But I'm not worry about it.<br>
IMO, no one will not pass this instance of object to
KimchiException as args.<br>
</blockquote>
IMO, we should never trust that the users/developers will pass the
correct parameters to our code. Eventually, someone will forget
that, and then we will have one more bug ;)<br>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
Thanks and best regards!
Sheldon Feng(冯少合)<a class="moz-txt-link-rfc2396E" href="mailto:shaohef@linux.vnet.ibm.com"><shaohef@linux.vnet.ibm.com></a>
IBM Linux Technology Center</pre>
</body>
</html>