Select to view content in your preferred language

String Parameter

809
0
12-02-2011 05:56 PM
ScottOatley
Emerging Contributor
Greetings:

I've got a simple script with a single parameter of type string. The script does a field calculate of the entered value into a field of type string. Here's the code:

import arcpy

mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd)[0]
s = arcpy.GetParameterAsText(0)

arcpy.AddMessage(type(s)) # displays type as 'unicode'

for lyr in arcpy.mapping.ListLayers(mxd):
    if lyr.isFeatureLayer:
        arcpy.CalculateField_management(lyr,"myfield",s)

del mxd


When I run the script, I have to wrap the input value in double quotes for it to work. I would have thought that wasn't needed since the parameter is of type string, and the parameter is brought in using GetParameterAsText. Is there some setting I'm missing that's causing this?

Thanks,
Scott
Tags (2)
0 Kudos
0 Replies