Hi Deny, Just to clarify your issue, are you hoping to iterate over the fields of, for instance, a GoogleAdsRow object, which can have varied fields depending on the query you sent, (i.e. row.campaign, row.metrics, etc)? If so I can see why it's confusing, because those objects aren't like dicts, where you can simply use a for loop to easily access each field.
For background, these objects are protobuf message instances and behave quite differently from other traditional Python objects. I admit that the interface these objects present is definitely confusing and not Pythonic at all, and in fact we're working to make the surface more sensible and hope to produce a number of improvements in the future. In the meantime, it's possible to know from the request object which fields are present on each GoogleAdsRow instance, here's an example using search_stream: import functools # Borrowed from: https://github.com/googleads/google-ads-python/blob/master/google/ads/google_ads/util.py#L51 def get_nested_attr(obj, attr, *args): def _getattr(obj, attr): return getattr(obj, attr, *args) return functools.reduce(_getattr, [obj] + attr.split(".")) for batch in response: fields = batch.field_mask.paths for row in batch.results: for field in fields: # field will be a str path, i.e. "campaign.id" or "metrics.average_cost" value = get_nested_attr(row, field) # you can also define logic based on the field name if "campaign.id" in field: # do something That's not particularly elegant, but it might be a bit faster than your solution that requires the entire object to be serialized. Like I mentioned, making this interface simpler is a big priority for us. If you have any other issues/questions/feature requests related to this it may be better to post directly on our Github Issues Tracker. In Github you can also keep track of new releases/changes and hopefully we'll be able to release some improvements there soon. Best, Ben Karl, Google Ads API Team ref:_00D1U1174p._5004Q25Wv5e:ref -- -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ Also find us on our blog: https://googleadsdeveloper.blogspot.com/ =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ You received this message because you are subscribed to the Google Groups "AdWords API and Google Ads API Forum" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/adwords-api?hl=en --- You received this message because you are subscribed to the Google Groups "AdWords API and Google Ads API Forum" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/1Y4lL000000000000000000000000000000000000000000000QITEIA00O09LvF0nT7e5UadKKYYSlg%40sfdc.net.
