how best to use a dictionary in this function?
Tim Roberts
timr at probo.com
Sun Oct 5 01:10:40 EDT 2008
Terrence Brannon <metaperl at gmail.com> wrote:
>
>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
You can also write it this way.
clicks = {
'std': std_clicks,
'vid': vip_clicks
}
>I know there is something like *args, or **args, but since
>docs.python.org is down, I cant check.
The problem with using **args is that you can no longer pass your
parameters positionally. Callers of calc_profit would have to use named
parameters. It also makes your default arguments a bit less natural.
--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the Python-list
mailing list