Empty input in Python 3 script

I seem to have hard time getting the Python 3 component in grasshopper to identify when any give input is empty. Previously I have used IronPython and there this has worked fine. What am I missing here or is there some other way to check empty input in Python 3?

A simple example showing IronPython and Python 3 difference in handling the same code:


Rhino version: 8.16.25042.13001, 2025-02-11

Very interesting, I like coding and would like to try it
Please tell me some articles where I can learn basic things

Interesting. I noticed that if I put “No type hint” for the input x in Python 3 component, it works correctly.

What type hint were you using in the CPython component screenshot above? I can’t reproduce the behaviour you’re describing with the ghdoc Object and No Type Hints in Rhino 8.17.25056.13001:



250228_TypeHintsPythonNone_00.gh (2.7 KB)

Maybe try posting a file to validate if it’s a version issue. Or that something else is going on.

Now that I tried with different type hints, it seems that at least integer, point 3d, float and boolean type hints work differently than “no type hint” option. I didn’t try all the type hints.


Type_hints.gh (17.9 KB)

Nice test matrix. Can confirm, there’s definitely something fucky here. Time to page Dr @eirannejad:

1 Like

@Lauri_Hautala @AndersDeleuran Looking at this right now and will update this post, however, on a quick look, the float, bool, int, and Point3d (struct) types are Value Types meaning they can not be NULL. So there is always a default value. I think that’s the bug in the Type Hints.

RH-86354 Value Type Hints always provide a value

Okay turned out this was a bug in Python 3 exec code. Fixed for next 8.x SRC. Now Python 2 and 3 behave the same


C# is special though since it does not allow non-nullables to be NULL. So they will adopt the default value for the type. Alternative is to use nullable types like int? but that introduces a whole set of other problems.

2 Likes

RH-86354 is fixed in Rhino 8 Service Release 18 Release Candidate