candide <cand...@free.invalid> wrote:

> Each of the following two functions mult1() and mult2() solves the
> question :
> 
> 
> # -----------------------------------------
> def mult1(a,b,m):
>     return (x for x in range(a,b)[(m-a%m)%m:b:m])
> 
> def mult2(a,b,m):
>     return range(a,b)[(m-a%m)%m:b:m]
> # -----------------------------------------
> 
> 
Why are you slicing the result of range? Why not just pass appropriate 
arguments to range or xrange directly?

def f(a,b,m):
        return xrange((a+m-1)//m*m, b, m)

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to