Skip to main content
Question

python

  • October 2, 2019
  • 1 reply
  • 14 views

terezia86
Forum|alt.badge.img

Hi,

can someone help me with the Python expression, please...

I need to get a summary of "sum A" and "Sum B"

wenn I write: "sum A"+"sum B" I get an result: "sum Asum B"

theese "sum A" and "sum B" must be written as a string, because I get this sum from calculating a few fields.

 

 

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

1 reply

david_r
Celebrity
  • October 2, 2019

If you have two attributes entering a PythonCaller named "sum A" and "sum B" containing numbers, you can do

sum_a = float(feature.getAttribute('sum A') or 0)
sum_b = float(feature.getAttribute('sum B') or 0)
feature.setAttribute('total', sum_a + sum_b)

This will output a new attribute 'total' that contains the sum of these two numbers.

If this is not what you mean, we need a bit more context.