How to concatenate 'str' and 'int' objects with python

3273
2
Jump to solution
06-06-2016 10:33 PM
AndrewNeedham
New Contributor III

Hi All,

I'm trying in a GDB using Arc10.2 to run a field calculate, into a text field using: "!SHAPE.firstpoint.X! &" "& !SHAPE.firstpoint.Y!" (without quotes) but this gives an error: 00539

  • cannot concatenate 'str' and 'int' objects

What would be the correct syntax?

I believe I need to cast but not sure how.

So far my workaround is to create a StartX and StartY field then combine them into another field StartXY, but this can be time consuming with a large number of records. There should be a better way.

!SHAPE.firstpoint.X! = 534792.9044

!SHAPE.firstpoint.Y! = 6917050.0155

End result should look like this:

534792.9044 6917050.0155

Cheers

0 Kudos
1 Solution

Accepted Solutions
FC_Basson
MVP Regular Contributor

Try this:

str(!SHAPE.firstpoint.X!) + " " + str(!SHAPE.firstpoint.Y!)

View solution in original post

2 Replies
FC_Basson
MVP Regular Contributor

Try this:

str(!SHAPE.firstpoint.X!) + " " + str(!SHAPE.firstpoint.Y!)
AndrewNeedham
New Contributor III

Thanks for that

0 Kudos