Is anyone else out there undergoing a conversion project to get python scripts written for 9.3 to work in 10? I'm wondering if there is a guide to the common things that need to be changed? If it is absolutely necessary to upgrade to arcpy and what kinds of experiences people have had doing this? I am trying to convert about 30 scripts and it's a big job. Besides the find and replace with gp to arcpy I'm finding alot of case sensitive issues like SearchCursors next() method which cannot be Next() like it used to. Right now I'm stuck on
That is helpful, thanks for that link. For others running into this same conversion process it would be great if esri had a white paper or guide to the conversion process. But we can start one here:
1. replace 'import arcgisscripting' with 'import arcpy' 2. remove gp = arcgisscripting.create(9.3) 3. find and replace all 'gp.' with 'arcpy.' 4. modify environment vars like 'gp.extent' to read 'arcpy.env.extent' 5. check your case sensitivity for method calls like next() on a SearchCursor (not Next())
Two reasons why you should switch to arcpy: 1. You can use a for loop to iterate cursors in arcpy which is better than while loops. 2. arcpy.mapping lets you edit mxds programatically. Case sensitivity is irritating though. getValue() not getvalue() or GetValue()
The very latest issue i have been dealing with is converting a script that handled some shapefile exports using the fieldMap and fieldMappings objects in arcpy. Once again the issue was with case sensitivity. The aliasName, outputField, and name methods have to begin with lowercase as they are listed in the docs. No errors are thrown if you have the incorrect case making it tough to track down these kinds of bugs. My best advice is to go through the docs for each method you call and see if you have the case correctly spelled. the next() method is used on cursors so i would check that you have the exact spelling and case syntax when creating the cursor and using it.
In arcpy you dont need to use next() in your cursors. Using next() was to force the cursor to advance to the next row in the table when using a while loop. Now that you can use a for loop next is not needed as for has better built in iterator functions. for row in arcpy.SearchCursor(featureclass): do some stuff and automatically go to the next row
You do not need to do anything to make your scripts work in 10.0, all previous functionality with the geoprocessor object will continue to work unmodified.