Unicode strings
I can think of nothing else that has caused programmers more confusion than Unicode strings. I will not even attempt to explain the issues surrounding Unicode, but I feel it's important to bring up so when you see something like the following, you will be prepared.
>>> import pymel.core as pmc >>> xform = pmc.polyCube()[0] >>> myname = 'cubexform' >>> xform.rename(myname) >>> xform.name() u'cubexform'
Unicode strings in Python 2 are prefixed with a u
character. So how come even though we named our node using a "regular" (byte) string with no prefix, we got back a Unicode string from the xform.name()
method?
Well, "regular" strings in Python 2 (the str
type) support ASCII characters only. ASCII is able to represent a very limited number of characters, but all the characters of the world can be represented by the Unicode system. So if you are creating a program that needs to be localized...