[Tutor] Beginner question (variables, namespaces...)

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Sat Apr 8 02:09:41 CEST 2006


> > buy_containers = roundup(need/container)
>
>
> Yeah, rather than code these as explicit variables, I'd strongly recommend
> rewriting each of these as functions.  Concretely:
>
> def buy_containers(stock, weekly_quota, container):
>     return roundup(need(stock, weekly_quota) - extra(stock, weekly_quota))

Gaaa.  I don't know where the heck that function came from.  *grin*  Let
me try that again:

#########################################################
def buy_containers(stock, weekly_quota, container):
    return roundup(need(stock, weekly_quota) / container)
#########################################################

Sorry; my eyes must have been wandering when I was writing that code.



More information about the Tutor mailing list