I tried to modify the code given in https://gis.stackexchange.com/a/212762/7849 so the value from [field_name] would be divided by the length of the feature. I tried to change the last line in
return sum( f[field_name]/f.geometry().length() for f in features if geometry.contains(f.geometry()) )
But I get an error: 'builtin_function_or_method' object has no attribute 'length'
f.geometry().length
without the end parentheses?features
is not a QgsFeatureIterator.<qgis._core.QgsFeatureIterator object at 0x000000000F5CC598>