Complete IPv4 class that can represent a host or network, and iterate over networks. Supports slash notation, stringifying, and range generation (among other things).
1 2 3 4
Too big to paste here. Get it from here: http://code.google.com/p/pycopia/source/browse/trunk/core/pycopia/ipv4.py
This class should handle just about any IP address related operation. If it doesn't handle yours please let me know.