I have this code:
fields = ['name','email']
def clean_name():
pass
def clean_email():
pass
How can I call clean_name()
and clean_email()
dynamically?
For example:
for field in fields:
clean_{field}()
I used the curly brackets because it's how I used to do it in PHP but obviously doesn't work.
How to do this with Python?
Question&Answers:os