gisrsbryce

Python syntax help, output to new Feature Class

Discussion created by gisrsbryce on Apr 22, 2010
Latest reply on Oct 25, 2010 by gisrsbryce
My code looks something like this (below).
What I need is pretty simple, I just can't figure out the proper syntax. 
Basically I want to define some dates (def dates)
Some plant types (def plants)
and some abbreviations for those plant types (def Abvs)
and then I want to call those functions (I hope that's the correct term, I'm not a programmer as you can tell) as part of my output names.  If I can figure this out, this will save me soooo much time. 
I would really appreciate any thoughts on what to do here.

code....

# Create the Geoprocessor
import arcgisscripting
gp = arcgisscripting.create(9.3)

# Set a default workspace
gp.workspace = "C:\\working\\Physical\\pgdb"

#studyarea = SA04

def dates():
Date1 = SA04_Ph_0809
Date2 = SA04_Ph_1009

def plants():
plant1 = Absent
plant2 = Cabomba carolinia


def Abvs():
p1abv = Abs
p2abv = Cab


try:
    # Make a layer from the feature class
    gp.MakeFeatureLayer("C:\\working\\Physical\\pgdb\\testing.gdb\\Date1", "lyr1")

    # Select plants of a species type
    gp.SelectLayerByAttribute("lyr1", "NEW_SELECTION", " genspec1 = 'plant1'")

    # Add to previous selection
    gp.SelectLayerByAttribute("lyr1", "ADD_TO_SELECTION", " genspec2 = 'plant1")   

    # Write the selected features to a new featureclass named for date and plant type
    gp.CopyFeatures("lyr1", "C:\\working\\Physical\\pgdb\\testing.gdb\\SA04_out\\Date1 + "_" + p1abv")


except:
    # If an error occurred print the message to the screen
    print gp.GetMessages()

Outcomes