Count the number of 0s at the ends of each of these:
>>> f('10.0.0.0'). # *
'0x0a000000'
>>> f('172.16.0.0')
'0xac100000'
>>> f('192.168.0.0')
'0xc0a80000
People whinge about IPv6 not being worth it but two of the things included in its ergonomics are hexadecimal address notation and netmasks that are multiples of 4.And IPv6 addresses are long and unmemorable? Addresses that you actually need to memorise are, in practice, only as long as your routing hierarchy is deep.
Your site:
2001:db8:60::/48
Your office LAN: $site:12
Your printer: $site:12::4
* >>> f = lambda q: '0x{:08x}'.format(reduce(int.__or__, (n << i * 8 for n, i in zip(map(int, q.split('.')), reversed(range(4))))))