For loop for different values in a field

Discussion created by kpearson272 on Mar 28, 2013
I have the following python script that creates a feature layer from an attribute selection.  The layer ???zipcodes??? has a field with multiple zipcodes and instead of writing the following code over again for each particular zipcode I want to write a for loop that performs the following for each separate zipcode.

import arcpy
arcpy.env.overwriteOutput = True
arcpy.env.workspace = "workspace path"
zipcodes = "shapefile location"
parcels = ???sde feature location???
arcpy.MakeFeatureLayer_management(zipcodes, "zipcodes_lyr")
arcpy.SelectLayerByAttribute_management("zipcodes_lyr", "NEW_SELECTION", """ "NAME" = '27012' """)
arcpy.CopyFeatures_management("zipcodes_lyr", "zip27012")
arcpy.MakeFeatureLayer_management(parcels, "parcel_lyr")
arcpy.SelectLayerByLocation_management("parcel_lyr", 'HAVE_THEIR_CENTER_IN',
                                       " zip27012.shp")
arcpy.CopyFeatures_management("parcel_lyr", "27012")

I have gotten as far as getting the value of the different zipcodes, but how would I write it so that I can create a selection of parcels by the selection statement?
import arcpy
import os
import sys

zipcodes = "zipcodes.shp"
name = "NAME"

rows = arcpy.SearchCursor(zipcodes)
row =

arcpy.MakeFeatureLayer_management(zipcodes, "zipcodes_lyr")

for row in arcpy.SearchCursor(zipcodes):
    value = row.getValue(name)

for value in row.getValue(name):