Overwrite files in Python Scripts ArcGIS 10

27527
7
09-02-2010 11:47 AM
MarkVolz
Occasional Contributor III
I would like to overwrite the outputs of my python geoprocessing script in ArcGIS 10.  How can I do this?
0 Kudos
7 Replies
ChrisSnyder
Regular Contributor III
In v9.3 it was:

gp.overwriteoutput = True

So I am assuming in v10 it would be:

arcpy.overwriteoutput = True
0 Kudos
MarkVolz
Occasional Contributor III
Chris,

Thank you for your reply.  Unfortunatly I was unable to get the code to work with arcpy.OverwriteOutput = True or arcpy.OverwriteOutput = 1
0 Kudos
JoeFlannery
Occasional Contributor III
Mark:

I was successful in ArcGIS 10 using:

# Overwrite pre-existing files
arcpy.env.overwriteOutput = True

In Python, I think that upper/lower-case text makes a difference in successful coding.
0 Kudos
ChrisSnyder
Regular Contributor III
Oh my, that's so ESRI...

I have a A LOT of code to rewrite!
0 Kudos
JohnSchmid
New Contributor
This frustrated me for an hour. arcpy is INDEED case sensitive, but the real crime is that ALL OVER esri help docs there is varying case used as if it would work in the examples. On top of that, most examples never show the env module, and show it this way (which will not work!!):

arcpy.overwriteOutput = True

(I've even seen this in the esri help docs, which will not work: arcpy.env.overwriteOutput = true)

when it should be:

arcpy.env.overwriteOutput = True

IN THE HELP docs for Heaven sakes!!!! ESRI, tidy up the help docs!!!!! HOUSEKEEPING!
Lake_Worth_BeachAdmin
Occasional Contributor III

I mean to be fair, all True values need to be True and not true in python. but agreed its a typo and should be fixed. 

0 Kudos
DanPatterson_Retired
MVP Emeritus
You would be advised to rely on your Python IDE (eg. PythonWin, Pyscripter etc) to obtain a list of applicable functions and help.

>>> dir(arcpy.env)
['MDomain', 'MResolution', 'MTolerance', 'XYDomain', 'XYResolution', 'XYTolerance', 'ZDomain', 'ZResolution', 'ZTolerance', '__class__', '__delattr__', '__delitem__', '__dict__', '__doc__', '__format__', '__getattribute__', '__getitem__', '__hash__', '__init__', '__iter__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_environments', '_gp', '_refresh', 'autoCommit', 'cartographicCoordinateSystem', 'cellSize', 'coincidentPoints', 'compression', 'configKeyword', 'derivedPrecision', 'extent', 'geographicTransformations', 'items', 'iteritems', 'keys', 'maintainSpatialIndex', 'mask', 'newPrecision', 'outputCoordinateSystem', 'outputMFlag', 'outputZFlag', 'outputZValue', 'overwriteOutput', 'projectCompare', 'pyramid', 'qualifiedFieldNames', 'randomGenerator', 'rasterStatistics', 'referenceScale', 'scratchWorkspace', 'snapRaster', 'spatialGrid1', 'spatialGrid2', 'spatialGrid3', 'terrainMemoryUsage', 'tileSize', 'tinSaveVersion', 'values', 'workspace']

As indicated, there are places where case-sensitivity or examples are lacking....report them, they are usually on the fixes quickly.

Also, use the online help and NOT the help built into the software, the former is updated regularly, the latter is not

http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html?TopicName=welcome
0 Kudos