If you're reading this, we've just migrated servers! If anything looks broken please email dion@thinkmoult.com :)
[Python] How is it possible to use colon to declare an variable?!
so i watched the Python crash course video for Blender recommend from here https://wiki.osarch.org/index.php?title=Start_coding
And in the video (43 min) he uses colon between noice_scale and FloatProperty
How is that possible in python syntax?
Comments
not an expert, but i think...
https://docs.python.org/3/glossary.html#term-variable-annotation
Prior to Blender 2.8, props were assigned with the equal sign, and now are indeed treated as annotations:
https://wiki.blender.org/wiki/Reference/Release_Notes/2.80/Python_API/Addons#Class_Property_Registration
This is indeed a python annotation.
In the context of Blender's python API it is used to dynamically populate the operator instances that are crated at runtime when you click on an operator's button. You can then access these properties as standard members of the operator instance.
In order for the API to recognize them you have to declare them as annotations. Otherwise they're just plan old python attributes of the main operator class (except the few attributes beginning with
bl_
).