dodgyshamrock

code working in PythonWin but not ScriptTool!

Discussion created by dodgyshamrock on Nov 29, 2011
Latest reply on Nov 30, 2011 by dodgyshamrock
Not quite sure how to phrase this question succinctly...  I have a really long code that is working just fine until it gets to a certain point where I am trying to format some list output.  The elements of the list will then be used to populate a table in an Access database.  I've split the list part of the code out and run it in PythonWin and it works.  However, when I run the entire code through the toolbox as a script tool I get this error:

'unicode' object is not callable

on this line:

finalList = [elt[0] + " (" + elt[1] + ")" if type(elt) == list and elt[0] == "ETSc" else str(elt) for elt in outlist]


Is the problem running it through a script tool?  And how would I fix it?  I can't post the entire code as it is over 300 lines but am posting the relevant part below:

#Get ETSc tables
#
obstable = "L:\\Projects\\IFWapplications\\ETSc\\ETSc.mdb\\tblObservation"
LUtable = "L:\\IFW-Data\\ETSc.gdb\\tblSpatialLU"
SpTab = "L:\\Projects\\IFWapplications\\ETSc\\ETSc.mdb\\tblSpecies"

#Create empty lists
ObsIDList = []
SpeciesList = []
ImpactList = []
outlist = []
finalList = []

#Use Cursor to determine if there is an ETSc record
#
try:
    HabCur = arcpy.SearchCursor(ProjectSF)
    for row in HabCur:
        VerId = row.getValue("ERVerID")
        ImpactList.append(VerId)
        habval = row.getValue("HABTYPE")
        if row.HABTYPE == "ETSc":
            EtscList = []
            outetsclist = []
            EtscList.append(habval)
            FID = row.getValue("FEATID")
            fld = "ShapeID"
            whereclause = fld + "=" + "'" + FID + "'"
            LUCur = arcpy.SearchCursor(LUtable, whereclause)
            for row in LUCur:
                obsnum = row.getValue("ObsID")
                ObsIDList.append(obsnum)
            del LUCur, row
            for obs in ObsIDList:
                scr = arcpy.SearchCursor(obstable)
                for row in scr:
                    if row.getValue("ObsID") == obs:
                        sp = row.getValue("Species")
                        SpeciesList.append(sp)
                del scr, row
            for species in SpeciesList:
                spcur = arcpy.SearchCursor(SpTab)
                for row in spcur:
                    if row.getValue("SciName") == sp:
                        CommonName = row.getValue("CommonName")
                del spcur, row
                EtscList.append(CommonName)
                for element in EtscList:
                    if element not in outetsclist:
                        outetsclist.append(element)
            ImpactList.append(outetsclist)
        else:
            ImpactList.append(habval)

    #get a list with unique values
    for I in ImpactList:
        if I not in outlist:
            outlist.append(I)

    arcpy.AddMessage(str(outlist))            

    #format elements in list
    finalList = [elt[0] + " (" + elt[1] + ")" if type(elt) == list and elt[0] == "ETSc" else str(elt) for elt in outlist]

Outcomes