Wednesday, November 09, 2005

Design Mistake?

Despite people's raving about Python's OO support, I think it's a design mistake that functions are mixed into the language for some reason unknown to me. For example, instead of calling string.length in other languages, you call len(string). Most other string operations are part of the string class, but why not lenght?

Another example of oddity, in dealing with unicode you can encode a string using the encode method of a unicode string:
u"你好吗“.encode("utf-8")

To convert back to unicode, you need to do this:
unicode(u"你好吗“.encode("utf-8"), "utf-8")

0 Comments:

Post a Comment

<< Home