base converter

Jeroen Wolff jwolff at knoware.nl
Thu Jun 14 00:59:16 EDT 2001


On Wed, 13 Jun 2001 22:01:08 GMT, "Fredrik Lundh"
<fredrik at pythonware.com> wrote:

>(why has decimal to binary conversion suddenly turned into a
>FAQ the last few months?  it wasn't this way in the old days,
>and I cannot remember ever having to output things as binary
>numbers in a real-life project...  can anyone explain?)
>
></F>
>
Me it is to convert an ip addresses like (192.168.2.1/24) into a 32
bits integer. Also the mask i wil convert to a 32 bit interger. Via
converting the 4 octets into its binary representation. Put all the 32
bits in a string and convert it to a interger. After that i can do an
AND between these two integers and calucate the network part of it. 

Wat i would like to have is a database of ip records. With ip number
and mask stored as an integer. This way i can lookup an ip addres in
the database and find out to wich (sub)network a.i. customer it
belongs....

Maybe i'm on the wrong track to solve my problem.....

Jeroen



More information about the Python-list mailing list