Repeat a Python function multiple times I am writing a Python script, and I need to repeat one line of code 24 times. How can I do that? I tried a for and while loop, and still cannot get it to repeat.

import bpy

def selectView():
    bpy.context.area.type = 'VIEW_3D'
    screen = bpy.context.window.screen
    for area in screen.areas:
        if area.type == 'VIEW_3D':
            for region in area.regions:
                if region.type == 'WINDOW':
                    override = {'window': bpy.context.window, 'screen': screen, 'area': area, 'region': region}
                    for i in range(0, 23):               
                        bpy.ops.view3d.view_orbit(override, type='ORBITDOWN')
                        bpy.ops.view3d.select_border(override, gesture_mode=3, xmin=-1200, xmax=1000, ymin=-1000, ymax=1000, extend=True)
                        print(i)
selectView()
bpy.context.area.type = 'TEXT_EDITOR'


What this is supposed to do is go in a circle and select the vertices on the outside of a model. Unfortunately, it is only moving the camera once and selecting everything.

Thanks for the help!
While I think there must be a more elegant way to accomplish what you are trying to do, the problem lies in the fact that Blender isn't updating the scenegraph when it's deep inside the Python loop.

You can force an update and redraw with:

# bpy.types.Scene.update()
bpy.context.scene.update()


and 

bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)


Note: calling bpy.ops.wm.redraw_timer is very much a hack, since scripts are not supposed to be forcing redraws, however it does work.