How do I make a script to set object index for every object? I wat to make a script that will, for every mesh in the scene, set a different object pass index so I don't have to select every mesh in my scene to assign a different number. I know this is possible via scripting, but I have no idea how to go about it.
A simple way to do this would be:

import bpy

pi = 0
for obj in bpy.data.objects:
    obj.pass_index = pi
    pi += 1