I think simply this will do with VBScript, using your example of 10 fields to choose from by index (0-9):
int(10*rnd)
...and with a Python codeblock using numpy:
import numpy.random as R
def getRandom(numFlds):
return int(R.random()*numFlds)
The above Python block would be called by (again using a 10 field example):
getRandom(10)
Extending this a little, let's say you wanted to use the random index generated to return the actual field names (instead of the index), then this is convenient using Python (uses the 1st layer in the default data frame):
import numpy.random as R
Flds = arcpy.ListFields(arcpy.mapping.ListLayers(arcpy.mapping.MapDocument('CURRENT'), '*')[0])
numFlds = len(Flds)
def getRandom():
return Flds[int(R.random()*numFlds)].name
Of course, if you're calculating this in a 'draft' field appended to the end of the same table the calculation is based on, and you don't want to include this field in the random generator, then you can simply subtract the number of 'draft' fields from numFlds var before the def declaration, i.e., if just one text field is appended to the end of the table to hold this calculation (and is to be excluded), then numFlds = len(Flds) - 1 [instead of numFlds = len(Flds)].