How to access a variable of node safely?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By alexzheng

if the variable is not defined in the node, access it will crashed, how can I check if a variable is defined in the node?

:bust_in_silhouette: Reply From: kidscancode

You can use in for this:

if 'property_name' in $SomeNode:
    print("property exists!")

Thanks,it works

alexzheng | 2018-05-31 23:21