# How to exit from the camera view?

With this code fragment, I can enter the camera view correctly, but I'd like to be able to get out.

 for a in bpy.context.screen.areas:
if a.type == 'VIEW_3D':
for r in a.regions:
if r.type == 'WINDOW':
override = {'window': bpy.context.window,
'area': a,
'region': r,
'scene': bpy.context.scene,
'active_object': camera}
bpy.ops.view3d.object_as_camera(override)

• uh, is it important that you use python to exit? this can be done easily with a keyboard shortcut. – Millard Sep 29 '19 at 17:22
• @Millard it is not very important, but it is necessary to understand – Pastrokkio Sep 29 '19 at 17:28
• I was just making sure you wanted a python answer. I'm not sure how to do this in python, was just making sure you knew it could be done with a shortcut. lol. – Millard Sep 29 '19 at 17:30

You can use the view3d.viewnumpad operation.
Pass on the override context, just like in your example code. This snippet can also be used to enter the active camera's view.

bpy.ops.view3d.viewnumpad(override, type='CAMERA')