Select to view content in your preferred language

@ as a string decorator in Python?

617
3
06-12-2023 11:50 AM
Labels (1)
ErikAnderson
Occasional Contributor

I executed the arcpy.management.CalculateFields() tool in ArcGIS Pro and copied/pasted the Python Command to a text editor. In some cases, it prefixes the "fields" parameter with "@" as in fields = @"X !XY!.split("","")[0] #;Y !XY!.split("","")[1] #".

I'm unable to find anything that explains what the "@" is doing for the string value. The only uses I've found for it is as a matrix operator and for accessing SHAPE properties.

Tags (3)
0 Kudos
3 Replies
MapGrrl
Regular Contributor

It appears to be a "connector" to indicate that the following syntax is related to the SHAPE of the feature:

https://pro.arcgis.com/en/pro-app/latest/arcpy/get-started/reading-geometries.htm

Are the fields related to the geometry, by any chance? Like, the Shape, Shape_area, Shape_length, etc.? or are they descriptive attribute fields?

 

0 Kudos
ErikAnderson
Occasional Contributor

I used the CalculateFields() tool to set multiple fields, some of which were geometry-related. However, the "@" character appeared at the head of and outside the string.

0 Kudos
Shaun-Walbridge
Emerging Contributor

If you can share an example project with the behavior in the history, I think we can log this as a bug.

Cheers, Shaun

0 Kudos