I want to write a simple toggle for an existing UI Boolean property. Every time I run the following code Blender should either show or hide the name of the object in the Viewport, depending on the current state. It works fine, but I wondering if it is really necessary to to call the property 3 times for this easy task.
import bpy obj = bpy.context.active_object if obj.show_name == True: obj.show_name = False else: obj.show_name = True
Is there a more elegant way to write this?