Ok, here is some code:

def calc_profit(std_clicks, vip_clicks, ad_rate=200,
upline_status=None):
    payout = {}
    payout_std = std_clicks * rates['std'].per_click
    payout_vip = vip_clicks * rates['vip'].per_click


... now note that std_clicks and vip_clicks are passed to the
function.

Now, I improved this function this way:

def calc_profit(std_clicks, vip_clicks, ad_rate=200,
upline_status=None):
    clicks = {}
    clicks['std'] = std_clicks
    clicks['vip'] = vip_clicks

    payout = {}
    for member_type in rates:
        payout[member_type] = clicks[member_type] *
rates[member_type].per_click

But it seems wasteful to have to re-bind the passed-in function args
to a dictionary in the function. I think there must be some way to
improve this code and get the dictionary built without me manually
doing it...

I know there is something like *args, or **args, but since
docs.python.org is down, I cant check.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to