# None,Nan or NA as a return value

**URL:** <https://forum.inductiveautomation.com/t/none-nan-or-na-as-a-return-value/71782>\
**Category:** General Discussion\
**Created:** [March 29, 2023, 4:01pm UTC](https://forum.inductiveautomation.com/t/none-nan-or-na-as-a-return-value/71782 "2023-03-29T16:01:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alan\_Cannon](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alan_cannon/32/31171_2.png) [@Alan\_Cannon](https://forum.inductiveautomation.com/u/Alan_Cannon)\
**Post date:** [March 29, 2023, 4:01pm UTC](https://forum.inductiveautomation.com/t/none-nan-or-na-as-a-return-value/71782/1 "2023-03-29T16:01:58Z")

</div>

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

1. is this some sort of python thing?
2. can an environment variable be set for this? to be what we want or what?

curious mind.  
Thanks,  
Alan

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [March 29, 2023, 4:04pm UTC](https://forum.inductiveautomation.com/t/none-nan-or-na-as-a-return-value/71782/2 "2023-03-29T16:04:39Z")

</div>

`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".

---

<div class="post-metadata">

**Author:** ![Alan\_Cannon](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alan_cannon/32/31171_2.png) [@Alan\_Cannon](https://forum.inductiveautomation.com/u/Alan_Cannon)\
**Post date:** [March 29, 2023, 4:25pm UTC](https://forum.inductiveautomation.com/t/none-nan-or-na-as-a-return-value/71782/3 "2023-03-29T16:25:08Z")

</div>

sure thing.  
first place i found it was reading a string tag. editor says null and the [0].value of a tag gave me NONE

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/9/f9526d7cfab8c80e0903efd47dfbea6fff75a9db.png)  
then intentionally i called a runquery() where a column contains null and used .getValueAt(x,y)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/6/96ab9a50390a008b59559fa206aa68cf84f28810.png)

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..

Best,  
Alan

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 29, 2023, 4:29pm UTC](https://forum.inductiveautomation.com/t/none-nan-or-na-as-a-return-value/71782/4 "2023-03-29T16:29:25Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Alan\_Cannon](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alan_cannon/32/31171_2.png) [@Alan\_Cannon](https://forum.inductiveautomation.com/u/Alan_Cannon)\
**Post date:** [March 29, 2023, 4:59pm UTC](https://forum.inductiveautomation.com/t/none-nan-or-na-as-a-return-value/71782/5 "2023-03-29T16:59:45Z")

</div>

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() ??

thanks  
Alan

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 29, 2023, 5:04pm UTC](https://forum.inductiveautomation.com/t/none-nan-or-na-as-a-return-value/71782/6 "2023-03-29T17:04:10Z")

</div>

> <https://stackoverflow.com/questions/2020598/in-python-how-should-i-test-if-a-variable-is-none-true-or-false>

Since None is a special singleton, you check whether a given value is null using the referential equality operator, `is`. So `if myVariable is None:`.

You _never_ want to drive control flow from the string representation of anything besides literal strings. Python is object oriented. Take advantage.
