def bin_to_text(ip):
 if (len(ip) == 4):
  return ipv4_to_str(ip)
 elif (len(ip) == 16):
  return ipv6_to_str(ip)
 else:
  raise struct.error(('Invalid ip address length: %s' % len(ip)))

def bin_to_text ( ip ) : if ( len ( ip ) == 4 ) : return ipv4_to_str ( ip ) elif ( len ( ip ) == 16 ) : return ipv6_to_str ( ip ) else : raise struct . error ( ( 'Invalid ip address length: %s' % len ( ip ) ) )
converts binary representation to human readable ipv4 or ipv6 string .