Not sure where this belongs in the forum, but as a new developer to ignition i found this interesting and now have questions.
Normally when using an object where there is "Null" data i would have expected "" or null as a return len()=0, however i got a "None" len()=4 return when something is not present.
Question's
is this some sort of python thing?
can an environment variable be set for this? to be what we want or what?
None is Python's null, but you need to provide more context as to where you're encountering this. It sounds like you ran len() on a string containing the value "None".
so i found this odd.. to say the least, and yes i was doing some error checking between a value of null as a return and then double checking is my return value had a len()=0 for sanity , which is how i stumbled onto this nugget..
Null is null is null.
Python just uses a special singleton object it calls None as the null value. Because Ignition is just embedding a Jython interpreter, we're subject to the same semantics. It's all the same (lack of) value.
len(None) would not work, by the way. The only way you get a length of 4 from null/None is if you're directly or indirectly coercing it into a string first.
i was actually str() to see what was happening with my data.
what i was looking to do was as follows:
->Get my Tag Data<-
tempgTraceLogName = system.tag.readBlocking("[default]gStn_100/gTraceLogName")[0].value
-> evaluate if the container was null <-
if len(tempgTraceLogName) == 0:
but that failed which is why i went after the str() of the tag thinking this was my issue....
so my question then is whats the proper "string" handler recommended to use when evaluating the error of TypeError: object of type 'NoneType' has no len() ??