This is very simple question

Cameron Laird claird at lairds.com
Thu Apr 22 10:21:37 EDT 2004


In article <4087a0f6$0$25552$afc38c87 at news.easynet.fr>,
Nicolas Lehuen <nicolas.lehuen at thecrmcompany.com> wrote:
			.
			.
			.
>You can also use divmod :
>
>def decompose(i,base=2):
>    result=[]
>    factor=1
>    while i>0:
>        i,r=divmod(i,base)
>        if r:
>            result.append(r*factor) # or result.extend([factor]*r),
>depending on style
>        factor*=base
>    return result.reverse() # if you really want it reversed
			.
			.
			.
I agree that divmod() improves the algorithm, and thank
you for pointing that out.

I'm reasonably certain that the return value of reverse()
is not what you believe it to be.
-- 

Cameron Laird <claird at phaseit.net>
Business:  http://www.Phaseit.net



More information about the Python-list mailing list