Skip to content

Instantly share code, notes, and snippets.

@nad2000
Created June 6, 2013 01:25
Show Gist options
  • Save nad2000/5718669 to your computer and use it in GitHub Desktop.
Save nad2000/5718669 to your computer and use it in GitHub Desktop.
def straddr2int(addr):
"""
converts IPv4 address inot an integer
>>> str2int('192.168.129.43')
3232268587
"""
return reduce( lambda a,b: a<<8|b, map(int,addr.split('.')) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment