I have a function which queries a number of tables to render business cards. Depending on an organizations subscription there are five possible dictionaries to return. Since I always try to have one return statement in my functions I now have:
def details(): organization=address=telecom=plan=logo=tagline=image=text=cssfile=customcss=plugin=[] organization=db().select().first() if organization.planID==1: .... elif organization.planID==2: .... elif organization.planID==3: .... elif organization.planID==4: .... else: .... return dict(organization=organization,address=address,telecom=telecom,plan=plan, \ logo=logo,tagline=tagline,cssfile=cssfile,customcss=customcss,plugin=plugin) I wonder what the pros and cons are of having something like: def details(): organization=address=telecom=plan=logo=tagline=image=text=cssfile=customcss=plugin=[] organization=db().select().first() if organization.planID==1: .... return dict(organization=organization,address=address,telecom=telecom) elif organization.planID==2: .... return dict(organization=organization,address=address,telecom=telecom,\ logo=logo,tagline=tagline ) elif organization.planID==3: .... return dict(organization=organization,address=address,telecom=telecom,\ logo=logo,tagline=tagline,cssfile=cssfile) elif organization.planID==4: .... return dict(organization=organization,address=address,telecom=telecom,\ logo=logo,tagline=tagline,customcss=customcss) else: .... return dict(organization=organization,address=address,telecom=telecom,plan=plan, \ logo=logo,tagline=tagline,cssfile=cssfile,customcss=customcss,plugin=plugin) Kind regards, Annet