I've run into a similar problem as referenced here - Dynamic Method Call In Python 2.7 using strings of method names
Here's an example of what my working method call looks like, the method at the end is based on a given data type, in this case .string_value
:
tag.fields[field["key"]].string_value = field["value"]
However I won't always be assigning just strings as there are methods for other data types. I attempted a solution similar to the one referenced in the linked thread:
typer = getattr(datacatalog_v1.types.TagField, f"{field['type']}_value")
tag.fields[field["key"]].typer = field["value"]
With typer
being my new dynamic method call, but it's not working. I'm receiving this as an error - 'TagField' object has no attribute 'typer'
.
Any suggestions?