Select to view content in your preferred language

Calculate field expression for string concatenation - Python 3.5

3928
10
Jump to solution
07-11-2017 10:15 AM
TessOldemeyer
Regular Contributor

After updating a script from Python 2 to Python 3, I am now getting an 'ERROR 00539: Indentation Error: Unexpected indent <<expression>, line 1' on a line in my script. The line is not indented, and I tried removing all spaces and also re-adding spaces (ensuring no tabs were used). I am not sure where the error is. The line ran without error using Python 2.

 

This is the original line:

arcpy.CalculateField_management (SubLayer_pp_trans_GUJoin_UniqueSubs, "SUB1SUB2", ' [SUB_1] + "," + [SUB_2] ')

I've tried: 

arcpy.CalculateField_management(SubLayer_pp_trans_GUJoin_UniqueSubs,"SUB1SUB2",' !SUB_1! +","+ !SUB_2! ')

and (and various renditions of removing spaces)

arcpy.CalculateField_management(SubLayer_pp_trans_GUJoin_UniqueSubs,"SUB1SUB2",' [SUB_1] + "," + [SUB_2] ')‍‍

with no luck. Any suggestions? 

Thanks!

0 Kudos
10 Replies
RebeccaStrauch__GISP
MVP Emeritus

I converted it to a question and marked Dan's answer as correct.  If you need to change the "correct answer", you should be able to do that now.