What’s going on?
TIL (from GPT) :
In Dynamo, the reason your code is outputing False
when you input 5
from a code block, and Dynamo identifies the type as System.Int64
, is due to how Python within Dynamo handles data types. In Dynamo, numbers can be represented as System.Int64
or System.Double
(among others), which are data types from the .NET framework, rather than Python’s native int
and float
types.
When you use isinstance()
in a Python script within Dynamo, it checks against Python’s native types. Since System.Int64
is not directly recognized as Python’s int
, the check fails, leading to False
being output.
This seems like a bit of a bug… Will this maybe be ironed out in future releases?
Sort of is, sort isn’t. I agree it is confusing though. 64 big ints are a data type of their own in CS, longs (and floats > doubles). I believe they went this way so we wouldn’t run out of integers for elementIds as well as other reasons I’m probably not versed on
It could be considered a ‘feature’ of IronPython, CPython3 evaluates an integer from a code block as int
type
I ended up doing a catch all…
if isinstance(IN[0], (Int64, Double, int, float)):
But seems very OTT.
hi if you add 0 it’s a number otherwise error if this helps Sincerely
christian.stan
Explain
Int32
be like
a=IN[0]
Bool=a+0==a
OUT=Bool
I’m not in front of a computer to test Sorry
Cordially
Christian.stan
That’ll give me a load of errors if I’m testing for other things though…
What’s “” + 0 for example?
“”+0 = stringy zero