def infer_netmask(addr):
 addr = addr.toUnsigned()
 if (addr == 0):
  return (32 - 32)
 if ((addr & (1 << 31)) == 0):
  return (32 - 24)
 if ((addr & (3 << 30)) == (2 << 30)):
  return (32 - 16)
 if ((addr & (7 << 29)) == (6 << 29)):
  return (32 - 8)
 if ((addr & (15 << 28)) == (14 << 28)):
  return (32 - 0)
  return (32 - 0)

def infer_netmask ( addr ) : addr = addr . toUnsigned ( ) if ( addr == 0 ) : return ( 32 - 32 ) if ( ( addr & ( 1 << 31 ) ) == 0 ) : return ( 32 - 24 ) if ( ( addr & ( 3 << 30 ) ) == ( 2 << 30 ) ) : return ( 32 - 16 ) if ( ( addr & ( 7 << 29 ) ) == ( 6 << 29 ) ) : return ( 32 - 8 ) if ( ( addr & ( 15 << 28 ) ) == ( 14 << 28 ) ) : return ( 32 - 0 ) return ( 32 - 0 )
uses network classes to guess the number of network bits .