code: def inet_pton(af, addr):
      
      # Will replace Net/Net6 objects
      addr = plain_str(addr)
      # Use inet_pton if available
      try:
          return socket.inet_pton(af, addr)
      except AttributeError:
          try:
              return _INET_PTON[af](addr)
          except KeyError:
              raise socket.error("Address family not supported by protocol")
docs: Convert an IP address from text representation into binary form.