Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to write a script where you preemptively select features and then go to the tool which calls for the feature layer and it populates fields based on certain criteria which I will design of the selected features.

I am simply trying to populate fields right now using the Update Cursor, but the field still come up blank.

here is my code so far:

input= arcpy.GetParameterAsText(0)

fields= ['Conf','Com']
with arcpy.da.UpdateCursor(input,fields) as cursor:
    for row in cursor:
        row[0] == '2'
        del row
    del cursor

Why are the selected features, or any feature for that matter not updated?

share|improve this question
Do not del row. row[0]='2'. Also do not use word input, do not del cursor – FelixIP Jan 18 at 0:45
The title of your Q is misleading – FelixIP Jan 18 at 1:15
up vote 5 down vote accepted

To expand more on @FelixIP comment, your row[0] is not assigning a value since double "==" are used with a if conditional statement for evaluating a value to be true or false. Use single "=" for committing a value change instead. Also, since your cursor is used within a with loop you do not need to delete the cursor and row objects.

Try this instead for your example:

fc = arcpy.GetParameterAsText(0)
fields = ['Conf','Com']
    with arcpy.da.UpdateCursor(fc,fields) as cursor:
        for row in cursor:
            row[0] = '2'

To update only selected features you will have to make the input fc a feature layer first (use MakeFeatureLayer method) and then perform a Select Layer By Attribute or Select Layer By Location method before entering the cursor.

share|improve this answer
Best to avoid using the built-in input function as a variable. – Aaron Jan 18 at 8:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.