Assuming my_function() is located in my_apps.views I would like to import my_function dynamically without using something like exec or
my_function()
my_function
exec
def import_by_string(full_name): module_name, unit_name = full_name.rsplit('.', 1) return getattr(__import__(module_name, fromlist=['']), unit_name) exists = import_by_string("os.path.exists")