Timeline for Writing expression for field calculator in Python?
Current License: CC BY-SA 3.0
4 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Aug 3, 2016 at 14:05 | comment | added | Evan |
The expression parameter has to be a string so it is helpful to use the built-in format() method on the string to perform the inline substitution of denominator . You can have many substitutions. The {} notation serves as a placeholder and will fill them in the order you pass them in the parameters (e.g. '{}{}{}{}'.format('a', 'b', 'c', 'd') becomes abcd . More info here: docs.python.org/2/library/stdtypes.html#str.format
|
|
Aug 3, 2016 at 13:57 | comment | added | giscard78 |
Worked as expected on a test feature class, thank you so much! Question: Do you mind explaining why 1) the first part is entirely entered as a string and the denominator gets .format() , 2) what the { } do in the code, how does it know to reference to the denominator? Are there instances when multiple { } may be used? How would it know what to reference to?
|
|
Aug 3, 2016 at 13:54 | vote | accept | giscard78 | ||
Aug 3, 2016 at 13:36 | history | answered | Evan | CC BY-SA 3.0 |