| 
 Date: 03/21/07 (Code WTF) Keywords: no keywords Кусок кода из одного совместного проекта: 
def ip2long(ip):
    splittedaddr = ip.split('.')
    ipnum = 16777216*int(splittedaddr[0]) + 65536*int(splittedaddr[1]) + 256*int(splittedaddr[2]) + int(splittedaddr[3])
    return ipnum
def long2ip(ipnum):
    w = int ( ipnum / 16777216 ) % 256
    x = int ( ipnum / 65536 ) % 256
    y = int ( ipnum / 256 ) % 256
    z = int ( ipnum ) % 256
    ip = str(w) + "." + str(x) + "."+ str(y) + "." + str(z)
    return ip
P.S. Сам Питона не знаю, но думаю, что битовые операции в нем имеются.Source: http://community.livejournal.com/code_wtf/74034.html 
 |