find out if a class is registered?

Is it possible to find out if a class is registered - in particular, a panel class (bpy.types.Panel)?

If you try to unregister a class that isn’t already registered, that raises “RuntimeError: unregister_class(…): missing bl_rna attribute from ‘RNAMeta’ instance (may not be registered)”. I’m wondering if there’s a nice way to avoid that.

if hasattr(bpy.types, "YOUR_PT_panel_class"): ...

or simply catch the exception

try:
    bpy.utils.unregister_class(YOUR_PT_panel_class)
except RuntimeError:
    pass
3 Likes

Ah, thank you so much! I feel silly :rolleyes:

Although this reply is over 6 years old - it caused an “Aha! Moment” into understanding what is going on with bpy.utils.register_class". Thank you!