0

I have a series of functions that do some data cleaning.

def clean_field_1(field_1): 
    return field_1

for example.

When looping through a dict of fields, field_1 may not be there. But if it is I'd like to call clean_field_1().

for field in dict_object:
    fn_call = f"clean_{field}"
    fn_call(field)

That's to illustrate the goal. In this case that final line errors because the str object is not callable.

Or it's possible that my approach is totally off base and I need a different one. Thanks for any pointers.

wjandrea
  • 28,235
  • 9
  • 60
  • 81
sam
  • 653
  • 9
  • 21

0 Answers0