Python: how to execute generated code ?
- by Natim
Hello guys
I have this code, and I would like to use the app parameter to generate the code instead of duplicating it.
if app == 'map':
try:
from modulo.map.views import map
return map(request, *args, **kwargs)
except ImportError:
pass
elif app == 'schedule':
try:
from modulo.schedule.views import schedule_day
return schedule_day(request, *args, **kwargs)
except ImportError:
pass
elif app == 'sponsors':
try:
from modulo.sponsors.views import sponsors
return sponsors(request, *args, **kwargs)
except ImportError:
pass
elif app == 'streaming':
try:
from modulo.streaming.views import streaming
return streaming(request, *args, **kwargs)
except ImportError:
pass
Do you have any idea ?
Thanks