[Tutor] First realscript + Game of Life
Carlos
carloslara at web.de
Fri Nov 10 08:39:46 CET 2006
Hi,
> What?
> I think you're talking to someone else here, cause I have no idea what
> you mean.
> Copy binary numbers from memory?
> You mean from any arbitrary memory location you want?
> That sounds a lot like C++ pointers to me.
That was based on this:
> Hi Carlos,
> I hope this module would help you with the binary conversion part:
>
> <pycode>
> def tobits(inte,size = 3):
> """Copy an integer's bits from memory"""
> s=''
> for i in range(size):
> s += str((inte & (1<<i)) >>i)
> #bits are extracted right-to-left
> s = s[::-1] #reverse the result string
> print s
> return list(s)
> </pycode>
>
> <pyshell>
>
>>>> >>>test = tobits(30,8)
>>>>
> 00011110
>
>>>> >>>test
>>>>
> ['0', '0', '0', '1', '1', '1', '1', '0']
> </pyshell>
>
> Cheers,
> Rooy
But probably (surely) my interpretation is wrong. Hehe
And about:
> 89+11 = 100, which is longer than the list.
:-[
Thanks Luke.
Carlos
More information about the Tutor
mailing list