Skip to content

Instantly share code, notes, and snippets.

@kissgyorgy
Last active December 23, 2015 07:39
Show Gist options
  • Save kissgyorgy/6602353 to your computer and use it in GitHub Desktop.
Save kissgyorgy/6602353 to your computer and use it in GitHub Desktop.
Python: nested list fun
# very beautiful, readable code, isn't it? :D
shared_app_models = [app_model for app_models in [get_models(app) for app in map(lambda appstr: get_app(appstr.split('.')[-1]), getattr(settings, 'SHARED_APPS'))] for app_model in app_models]
shared_app_models = []
shared_apps = map(lambda appstr: get_app(appstr.split('.')[-1]), getattr(settings, 'SHARED_APPS'))
for app in shared_apps:
for model in get_models(app):
shared_app_models.append(model)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment