Python: how to execute generated code ?

Posted by Natim on Stack Overflow See other posts from Stack Overflow or by Natim
Published on 2010-05-19T17:57:53Z Indexed on 2010/05/19 18:10 UTC
Read the original article Hit count: 288

Filed under:
|
|

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

© Stack Overflow or respective owner

Related posts about python

Related posts about django