wannaz

CalculateField_management() crashing (I)Python

Discussion created by wannaz on Sep 3, 2010
Latest reply on Sep 5, 2010 by wannaz
Dear all,

    Is it clear to anybody why the following code crashes? It does crash when I am calling CalculateField_management() with a Python expression AND that my object name is "arcgis". It does NOT happen with a VB expression or when the object is named differently. To me, it is like CalculateField_management() is somehow getting out of its namespace to kill a resource named 'arcgis' in another namespace.. ?

   The following code (a dummy example that isolates my problem) crashes IPython and somehow kills my arcgis object in Eclipse (without crashing Eclispe) the first time I am calling CalculateField_Python() so the second call generates the traceback below:


--- START.

Call #1
Call #2
Traceback (most recent call last):
  File "C:\Users\wannaz\Documents\Eclipse\Workspace\ArcGIS - General\src\testCalculateField.py", line 28, in <module>
    arcgis.CalculateField_Python()
AttributeError: 'module' object has no attribute 'CalculateField_Python'


Does anybody understand or know a post related to similar issues?

Thank you and best regards,

Cedric



myWorkspace = r'C:\Users\wannaz\Documents\Projects\ArcGIS General\CrashCalculateField\scratch.gdb'


import arcgisscripting


class MyClass:
    
    def __init__(self, workspace):
        self.gp = arcgisscripting.create( 9.3 )
        self.gp.SetProduct( 'ArcInfo' )
        self.gp.Workspace = workspace
        self.gp.OverwriteOutput = 1

    def CalculateField_Python(self):
        expression = '!Shape_Length!'
        self.gp.CalculateField_management( 'testFC', 'testField', expression, "PYTHON_9.3" )



print '\n--- START.\n'

# Give the object any other name than 'arcgis' and it works..
arcgis = MyClass( myWorkspace )

print "Call #1"
arcgis.CalculateField_Python()

print "Call #2"
arcgis.CalculateField_Python()

print '\n--- END.'

Attachments

Outcomes