def processFeature(feature):
roleList = feature.getAttribute("tag{}.k")
print(roleList)
if roleList!=None:
for feat in roleList:
print(feat)
Above is my quite simple python code that successfully prints all key-values for the tag-list of OSM features. This works the same way in 2.7 and 3.4, as expected. However, if I change the attribute to print the member list instead, I get different behaviors between the two.
With the following code:
def processFeature(feature):
roleList = feature.getAttribute("member{}.ref")
print(roleList)
if roleList!=None:
for feat in roleList:
print(feat)
It prints nothing in Python 3.4 compat-mode, but does in 2.7 mode.
How come this happens? My initial thought was that since the member-list only contained one member, it would not treat it as a proper list, but even on features with several members, the behavior is the same.
My current workaround is to quite simply use Python 2.7, but this might not always be a good solution.