Comments and answers for "PythonCaller input loop" https://knowledge.亚搏在线safe.com/questions/32949/pythoncaller-input-loop.html The latest comments and answers for the question "PythonCaller input loop" Comment by slerendu on slerendu's comment https://knowledge.亚搏在线safe.com/comments/33110/view.html Ok,it's seems that I should have just one feature in the input instead of 2.A colleague of mine helped me on that.So problem solved.
Thanks anyway.I have a better understanding of the PythonCller thanks to you.

Wed,31 Aug 2016 12:33:53 GMT slerendu
Comment by slerendu on slerendu's comment https://knowledge.亚搏在线safe.com/comments/32958/view.html Ok,I understand.And you both are right for intention in this context.I'll try.Thanks.

Mon,29 Aug 2016 14:44:38 GMT slerendu
Comment by david_r on david_r's comment https://knowledge.亚搏在线safe.com/comments/32957/view.html The way the PythonCaller works is pretty simple and it is coherent with the way Python (and most OOP languagues) work in this type of pattern:

  • Before the first feature arrives: call__init__()once
  • For each feature: callinput()once per feature
  • After the last feature has passed: callclose()once
You may want to read up a bit on Python objects and particulary on scope,e.g. here.I agree with @verdoodtdries that it looks like a scoping error.

I do not quite understand what you really want to achieve,but I suspect you want to make myAnswerField an object instance variable (rather than a local variable,as it is now).You can do this by initalizing myAnswerField in __init__() and prefixing it with "self." whenever you reference it.

As it is you are effectively resetting (redefining) myAnswerField for every incoming feature,that may not be what you want?
Mon,29 Aug 2016 14:39:54 GMT david_r
Comment by slerendu on slerendu's answer https://knowledge.亚搏在线safe.com/comments/32955/view.html I thought it was a PythonCaller problem actually.Maybe I misunderstood.
Mon,29 Aug 2016 14:22:02 GMT slerendu
Comment by slerendu on slerendu's answer https://knowledge.亚搏在线safe.com/comments/32954/view.html
def input(self,feature):...myAnswerField = [('Echelle1',None),('Echelle2',None)]
if '01' in feature.getAttribute('id_reseau'): scale1 = feature.getAttribute('echellesortieplanprincipal') myAnswerFields.remove(('Echelle1',None)) myAnswerFields.append(('Echelle1',scale1)) if '02' in feature.getAttribute('id_reseau'): scale2 = feature.getAttribute('echellesortieplanprincipal') myAnswerFields.remove(('Echelle2',None)) myAnswerFields.append(('Echelle2',scale2))
with this database :

Mon,29 Aug 2016 14:21:18 GMT slerendu
Answer by verdoodtdries https://knowledge.亚搏在线safe.com/answers/32952/view.html

I think you are mixing up local and global variables,but please post your whole code so we can see what's going wrong.

Mon,29 Aug 2016 14:12:33 GMT verdoodtdries
Answer by david_r https://knowledge.亚搏在线safe.com/answers/32951/view.html

I suspect this question would be more suitable in a Python forum.

Anyway,it's difficult to help unless you post the whole code and tell us precisely what you want to achieve.

Mon,29 Aug 2016 14:10:17 GMT david_r