Skip to content

Instantly share code, notes, and snippets.

@SeavantUUz
Created November 27, 2013 14:50
Show Gist options
  • Save SeavantUUz/7676900 to your computer and use it in GitHub Desktop.
Save SeavantUUz/7676900 to your computer and use it in GitHub Desktop.
tirck codes
def fill_object(items,profiles,*args):
profiles_dict = {}
for profile in profiles:
profiles_dict[profile.id] = profile
for arg in args:
items = map(lambda o:_add_attr(o,profiles_dict,arg),items)
return items
def _add_attr(item,profiles_dict,arg):
profile = profiles_dict.get(item.id)
item.__setattr__(arg,getattr(profile,arg))
return item
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment