Skip to content

Instantly share code, notes, and snippets.

@alanbriolat
Created October 16, 2010 17:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alanbriolat/630048 to your computer and use it in GitHub Desktop.
Save alanbriolat/630048 to your computer and use it in GitHub Desktop.
Checking an IP address is within a range, the correct way (NOT using regular expressions!)
>>> ip = "192.168.75.10"
>>> a, b, c, d = map(int, ip.split('.'))
>>> a == 192 and b == 168 and 72 <= c <= 79 and 1 <= d <= 254
True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment