Blender Python Perspective Camaera

def main(context):
    
    if context.region_data.view_perspective in  {'PERSP','ORTHO'}: 
        context.region_data.view_perspective = 'CAMERA'
    else:                            
        context.region_data.view_perspective = 'PERSP'
    return {'FINISHED'}
HotFlow