[Tutor] First realscript + Game of Life

Luke Paireepinart rabidpoobear at gmail.com
Fri Nov 10 09:12:57 CET 2006


<snip binary function>
> But probably (surely) my interpretation is wrong. Hehe
>   
Ah, well, it's just the terminology you were using was a bit misleading.
You say
' Hey Rooy, so its possible to copy binary numbers from memory?'
All his function does is converts an integer (that's in memory, yes) 
into a binary number.
It doesn't copy the binary bit arrangement directly from memory.  It 
uses mathematical operations on an integer in base-10, that it gets from 
the binary in memory, to convert it to base-2.
You could do the same for 16, or 32, or 64, or base 256 numbers if you 
wanted to.
The point I'm trying to make is that it's not extracting the actual bits 
from the memory location or anything like that.
It's just converting bases.  It doesn't matter that the number is stored 
as binary cause to Python it's an integer.
Think of it like this.

This is what's happening
Memory       Python     Binary_function
[ 0000001] ->  1     ->    [0000001]


It's not going from here
Memory        Python
[0000100] ->    4

To here...

Memory        Python
[0000100] -> [0000100]

Do you see what I mean?
Python still sees the memory location as an integer,
so it still stores the value (within python) in base-10, not in base-2.
So even though the memory location has the actual bits, we can't access 
them.
We can only get access to the python base-10 value.
But it's fairly trivial to convert this integer into a binary list.
It _is_ going through 2 conversions, though, the binary isn't directly 
accessed, as I got the impression you thought.

' I had the impression that this could be done, but obviously it is too 
much for me. This way is going to be faster than the hack that I tried 
before, right? Thanks for the  module : )'
I didn't see the hack you did before, so I don't know.
But what he sent was a function, not a module.
A module is quite a bit more of a complicated beastie than a function is.
the wikipedia definition goes something like this:
'a *module* is a software entity that groups a set of (typically 
cohesive <http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29>) 
subprograms <http://en.wikipedia.org/wiki/Subprogram> and data 
structures <http://en.wikipedia.org/wiki/Data_structure>. Modules are 
units that can be compiled <http://en.wikipedia.org/wiki/Compiler> 
separately, which makes them reusable and allows multiple programmers to 
work on different modules simultaneously. Modules also promote 
modularity <http://en.wikipedia.org/wiki/Modularity_%28programming%29> 
and encapsulation (i.e. information hiding 
<http://en.wikipedia.org/wiki/Information_hiding>), both of which can 
make complex programs easier to understand.'
Not sure what exactly a module is (I get it confused with packages) in 
Python.
Perhaps someone can help here?
>> 89+11 = 100, which is longer than the list.
>>     
>
> Thanks Luke.
>   
Sure, glad to help  :-]


More information about the Tutor mailing list