This started off as being elegant...# Import arcpy module
import arcpy
# Parameters
input = "C:\\some feature class"           #input feature class
near = "C:\\some other feature class"    #near feature class
nearcount = "3"                                 #number of nearest features
output = "C:\\output table"                  #output table
# Fun stuff
# Process: Generate Near Table
arcpy.GenerateNearTable_analysis(input, near, output, "", "NO_LOCATION", "NO_ANGLE", "ALL", nearcount)
# Process: Add Field
arcpy.AddField_management(output, "rank", "SHORT", "", "", "", "", "NON_NULLABLE", "NON_REQUIRED", "")
rows = arcpy.UpdateCursor(output,"","","","IN_FID A; NEAR_DIST A")
count = 0
for row in rows:
    if count == 0:
        curID = row.IN_FID
    count = count + 1
    if row.IN_FID != curID:
        curID = row.IN_FID
        count = 1
    row.RANK = count
    rows.updateRow(row)
del row
del rows