On Oct 23, 2006, at 10:54 PM, sophana wrote:


I'm still suffering on the python bug when you add a string to an
unicode with +=, the string is encoded into ascii. I still don't
understand why python didn't merge unicode and strings.

Could you give an example? My understanding of what you write:

Python 2.4.4 (#1, Oct 18 2006, 10:34:39)
[GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
.>> s = u'hello'
.>> s += 'world'
.>> s
u'helloworld'
.>>

If you add a str() value to a unicode() using += this behaves just like I expect. As Markus already noted relying on this behaviour is bad outside of tightly contrained boundaries (such as when the str() value is a constant that you know to be ASCII). In general it is much better to be explicit about conversions between str and unicode, otherwise you'll one day run into input where the default conversion raises an exception.

Ronald


Attachment: smime.p7s
Description: S/MIME cryptographic signature

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to