Select to view content in your preferred language

Variable passing problem

2853
1
11-27-2014 08:51 PM
H_A_D_Padmasiri
Deactivated User

dear sir!

 

I wrote a python function to replace an attribute. But variable "a & b" not passing through CalculateField_management.

Can you give me an advice to correct it.

Thanks

 

Padmasiri

def foo(s1):

    return "'{}'".format(s1)

def BoundCal(a,b):

   New_Name = arcpy.AddFieldDelimiters(env.workspace, "PCL_LN_CD")

    where1 = New_Name + '=' + foo(str(a))

    arcpy.SelectLayerByAttribute_management("ABC_Lyr", "NEW_SELECTION", where1)

    arcpy.CalculateField_management("ABC_Lyr", "PCL_LN_CD", "!PCL_LN_CD!.replace(\"a\", \"b\")" , "PYTHON_9.3" "")

0 Kudos
1 Reply
DanPatterson_Retired
MVP Emeritus

and you tried?

"!PCL_LN_CD!.replace(\'a\', \'b\')"

0 Kudos