ArcLength is a string field with spaces, so the test will fail unless it converts the string to a number and tests for a space. IN works even if there are no listed object (nothing is selected but no error occurs), a single item, or a list of items, so the else clause is not necessary. = fails and produces an error if there is no listed objectID value or a list, so IN is all you need.
Richard,Which statement accounts for the ARCLENGTH field being a string with spaces? Because, if I use your example, I run into a RuntimeError: A column was specified that does not exist, in line 15. for row in rows:, but the error is probably in line 14, the SearchCursor.import arcpy
mxd = arcpy.mapping.MapDocument ("CURRENT")
df = arcpy.mapping.ListDataFrames (mxd)[0]
lyr = arcpy.mapping.ListLayers(mxd, "Lot_Lines", df)[0]
arcpy.AddMessage(lyr.name)
for lyr in arcpy.mapping.ListLayers(mxd):
dsc = arcpy.Describe(lyr)
sel_set = dsc.fidSet
myString = ",".join(sel_set)
rows = arcpy.da.SearchCursor(lyr, ["OID@", "ARCLENGTH", "Shape_Length"], "OBJECTID IN (" + myString + ")")
for row in rows:
arcLength = row.ARCLENGTH
shapeLength = row.Shape_Length
if len(arcLength) > 0:
arcpy.AddMessage("ArcLength = " + arcLength)
else:
arcpy.AddMessage("ShapeLength = " + str(shapeLength))
del row, rows