AnsweredAssumed Answered

Set gp.workspace with a Variable Read in from a Text File

Question asked by mvolz47 on Mar 22, 2012
Latest reply on Mar 23, 2012 by mvolz47
To All Python Users:

In ArcGIS v9.3.1 I want to be able to set certain variables such as the gp.workspace from a configuration file outside the python script so it is not hard-coded in the script.

I was able to read in text for other variables I needed to set but it did not work with gp.workspace as I received the following error:

Traceback (most recent call last):
  File "G:\deptdata\GIS\GIS_Services\User\server_Scripts\", line 37, in <module>
    gp.workspace = "'" + source + "'"
RuntimeError: NotInitialized

The code to set the variable source is as follows:

vars =",")  connSDE = vars[0] EOC_source = vars[1]  gp.workspace = "'" + EOC_source + "'"  (I have tried gp.workspace = """ + EOC_source + """ as well as gp.workspace = EOC_source 

Can gp.workspace be set with a variable?  If so, what am I doing wrong with the syntax?

Any help or hints regarding this issue are greatly appreciated.  Thanks.