SMUSEBY wrote:Perhaps it would help if I were to explain better my confusion. In the example,
myInteger = 1
indigo.variable.updateValue(1234567, value=unicode(myInteger))
there is the work, 'unicode'.
If one is conversant in Python, I suspect it's definitive.
unicode(
something) casts the variable
something into a unicode string. That is, it forces it into the type unicode string. A unicode string is just a string that support unicode characters. You can have strings that aren't unicode, but in-general Indigo likes unicode strings because it makes handing accented characters relatively straightforward. Just think of unicode as being a string for this discussion. Let's take another example:
someInteger = 5
someRealNumber = 5.0
someUnicodeString = u"hello world"
so above are 3 python variables. The variables internal type is defined by what you assign to the variable. The first is an integer type variable, the next a real number variable, and the last a unicode string. Indigo always stores variable values as unicode strings, and the updateValue expects a unicode string for that second argument. Given above if I were to do:
someUnicodeString = unicode(someRealNumber)
then someUnicodeString would now be a unicode string. That is it would be
u"5.0" and not
5.0. You can cast from one type to another just by using the type name and a parentheses. So after above I could then do this:
someInteger = int(someUnicodeString)
and that will set someInteger to be an integer with the value
5. Note if someUnicodeString isn't a number (say it was the unicode string u"hello world") then the line above would fail. You would get a python exception thrown because it isn't possible to convert "hello world" into an integer. You can always convert integers and real numbers to strings though, you just may not be able to convert in the other direction .