delaying the iteration of a loop

while doing some debugging for a new script i got some code from BA contributor crouch to redraw 3dview when needed in this example i use a forloop with time.sleep to pause the iteration. i have slightly rewritten this, but while crouch thinks this is ugly, i find it useful, and it may be to others too

import bpy
import time


areas = [area for area in bpy.context.screen.areas if area.type == 'VIEW_3D']    

def redrawView():
    for area in areas: 
        area.tag_redraw()

    bpy.ops.wm.redraw_timer(type='DRAW_SWAP', iterations=0)


for i in range(4):
    bpy.ops.mesh.primitive_cube_add(location=(i,0,0))
    redrawView()
    time.sleep(0.3)

Generally that is a bad way to do things. A better approach is to fire off a timer and put the delayed code in the timer event. Then you are not holding up processing.