Having trouble with python script

Discussion created by mmflynn on Nov 18, 2011
Latest reply on Nov 23, 2011 by mvolz47
My initial problem is I have a polygon layer and a point layer. I need to shade the polygons based on how many points they contain.

I've created a new field on the polygon layer, Num_of_points. The idea was to have a python script update this field and the symbology will be set to shade based on this field.

I'm very new to python and having trouble getting a script going.   I've been told I need an update cursor for the polygon layer
for each feature in the polygon layer
    selection by location( polygon feature, points layer, Intersect )
    get the count of points in the polygon
    polygon feature.set num_of_points = count found
    clear selection

I can write what I need to do in psudo code, but I'm having WAY more trouble with the python code.  Can anyone lend a hand with translating this to python?

Thanks so much,