iQuery = ' "Name" = \'Joe Blogs\' ' arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION", iQuery)
iPerson = ???Joe Blogs??? iQuery = '"Name" = "' + aCenterMapOn + '"' arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION", iQuery)
Solved! Go to Solution.
IDLE 2.6.5 >>> import arcpy >>> fc = r'C:\Documents and Settings\whitley-wayne\Desktop\stage.gdb\RightBankPoints' # (make sure the fc exists) >>> if arcpy.Exists(fc):print 'true' true # (could have entered the qry here for MFL, but you wanted to demo SelectLayerByAtt, which I think requires a layer) # (...so created a lyr first to feed into SelectLayerByAtt, a step only for demo purposes...) >>> arcpy.MakeFeatureLayer_management(fc, 'lyr') <Result 'lyr'> # (verifying there are features in the lyr): >>> arcpy.GetCount_management('lyr').getOutput(0) u'198' # (setting up the field with the correct delimiters [double quotes]): >>> selFld = arcpy.AddFieldDelimiters(fc,'RiverCode') # (just checking...) >>> print selFld "RiverCode" # (setting up the qry string): >>> qry = "%s %s" % (selFld, 'is not Null') # (looks fine, ready for launch...) >>> print qry "RiverCode" is not Null # (commence launch, the execution we've been waiting for): >>> arcpy.SelectLayerByAttribute_management('lyr', 'NEW_SELECTION', qry) <Result 'lyr'> # (checking the count -- I entered 1 null record, so the count should be at least 1 less than before): >>> arcpy.GetCount_management('lyr').getOutput(0) u'197' >>>