Struggling with seemingly simple RasterList and sum script: please HELP!

Discussion created by afenix on Apr 9, 2011
Latest reply on Apr 11, 2011 by csny490

I???ve gotten quite rusty on my Python over the years and have  now been stuck on a seemingly easy little script for far too long, and have officially reached the reaching out point.  Hopefully some python guru???s out there will be able to see what I???m doing wrong and point me in the right direction. 
Quick background: I???ve created a complex model whose output is a number of grids (will be in the order of over a thousand).  I now simply need to sum all of the grids together as my final output before I can complete the analysis.  Obviously, when you have over a thousand grids the option of manually adding names within raster calculator (or anywhere else for that matter) becomes obsolete.  So, here???s the script for listing the output rasters and summing them:


#Script to list each output raster and sum them
import arcgisscripting

#create the geoprocessor object
gp = arcgisscripting.create(9.3)

#check out any necessary licenses

#set up the local variables...
gp.workspace = "C:\\test\\results"
outputFolder = "C:\\test\\final"
    rasterList = gp.ListRasters("","GRID")
    print rasterList
    raster =
    print raster
    somaExp = " "
    while raster:
        soma = somaExp + raster + "+"
        print somaExp
        raster =
        gpsa = outputFolder + "\\"
        gp.SingleOutputMapAlgebra_sa(soma[:-1], gpsa)

#In the rare case that this script does not work...
    print "Nice try, but it didn't work."  


The ListRasters is working (although it is putting a ???u??? in front of the names), but I can???t get any other clues about why it keeps crashing.
I???m running ArcGIS 9.3 and python 2.5.1 on Windows XP.

Thanks in advance for any help!!!